• Home
  • Raw
  • Download

Lines Matching refs:btv

170 	struct bttv *btv = dev_get_drvdata(vfd->parent);  in show_card()  local
171 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); in show_card()
840 int check_alloc_btres(struct bttv *btv, struct bttv_fh *fh, int bit) in check_alloc_btres() argument
853 mutex_lock(&btv->lock); in check_alloc_btres()
854 if (btv->resources & xbits) { in check_alloc_btres()
860 && 0 == (btv->resources & VIDEO_RESOURCES)) { in check_alloc_btres()
862 __s32 top = btv->crop[!!fh->do_crop].rect.top; in check_alloc_btres()
864 if (btv->vbi_end > top) in check_alloc_btres()
869 btv->crop_start = top; in check_alloc_btres()
873 if (end > btv->crop_start) in check_alloc_btres()
877 btv->vbi_end = end; in check_alloc_btres()
882 btv->resources |= bit; in check_alloc_btres()
883 mutex_unlock(&btv->lock); in check_alloc_btres()
887 mutex_unlock(&btv->lock); in check_alloc_btres()
898 int locked_btres(struct bttv *btv, int bit) in locked_btres() argument
900 return (btv->resources & bit); in locked_btres()
905 disclaim_vbi_lines(struct bttv *btv) in disclaim_vbi_lines() argument
907 btv->vbi_end = 0; in disclaim_vbi_lines()
912 disclaim_video_lines(struct bttv *btv) in disclaim_video_lines() argument
917 tvnorm = &bttv_tvnorms[btv->tvnorm]; in disclaim_video_lines()
918 btv->crop_start = tvnorm->cropcap.bounds.top in disclaim_video_lines()
933 void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits) in free_btres() argument
939 mutex_lock(&btv->lock); in free_btres()
941 btv->resources &= ~bits; in free_btres()
943 bits = btv->resources; in free_btres()
946 disclaim_video_lines(btv); in free_btres()
949 disclaim_vbi_lines(btv); in free_btres()
951 mutex_unlock(&btv->lock); in free_btres()
967 static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout) in set_pll_freq() argument
989 static void set_pll(struct bttv *btv) in set_pll() argument
993 if (!btv->pll.pll_crystal) in set_pll()
996 if (btv->pll.pll_ofreq == btv->pll.pll_current) { in set_pll()
997 dprintk("bttv%d: PLL: no change required\n",btv->c.nr); in set_pll()
1001 if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) { in set_pll()
1003 if (btv->pll.pll_current == 0) in set_pll()
1006 btv->c.nr,btv->pll.pll_ifreq); in set_pll()
1009 btv->pll.pll_current = 0; in set_pll()
1013 bttv_printk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->c.nr, in set_pll()
1014 btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
1015 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
1026 btv->pll.pll_current = btv->pll.pll_ofreq; in set_pll()
1031 btv->pll.pll_current = -1; in set_pll()
1037 static void bt848A_set_timing(struct bttv *btv) in bt848A_set_timing() argument
1040 int table_idx = bttv_tvnorms[btv->tvnorm].sram; in bt848A_set_timing()
1041 int fsc = bttv_tvnorms[btv->tvnorm].Fsc; in bt848A_set_timing()
1043 if (UNSET == bttv_tvcards[btv->c.type].muxsel[btv->input]) { in bt848A_set_timing()
1045 btv->c.nr,table_idx); in bt848A_set_timing()
1055 btv->pll.pll_ofreq = 27000000; in bt848A_set_timing()
1057 set_pll(btv); in bt848A_set_timing()
1061 btv->pll.pll_ofreq = fsc; in bt848A_set_timing()
1062 set_pll(btv); in bt848A_set_timing()
1069 static void bt848_bright(struct bttv *btv, int bright) in bt848_bright() argument
1074 btv->bright = bright; in bt848_bright()
1081 static void bt848_hue(struct bttv *btv, int hue) in bt848_hue() argument
1085 btv->hue = hue; in bt848_hue()
1092 static void bt848_contrast(struct bttv *btv, int cont) in bt848_contrast() argument
1096 btv->contrast = cont; in bt848_contrast()
1106 static void bt848_sat(struct bttv *btv, int color) in bt848_sat() argument
1110 btv->saturation = color; in bt848_sat()
1113 val_u = ((color * btv->opt_uv_ratio) / 50) >> 7; in bt848_sat()
1114 val_v = (((color * (100 - btv->opt_uv_ratio) / 50) >>7)*180L)/254; in bt848_sat()
1126 video_mux(struct bttv *btv, unsigned int input) in video_mux() argument
1130 if (input >= bttv_tvcards[btv->c.type].video_inputs) in video_mux()
1134 mask2 = bttv_tvcards[btv->c.type].gpiomask2; in video_mux()
1138 if (input == btv->svhs) { in video_mux()
1145 mux = bttv_tvcards[btv->c.type].muxsel[input] & 3; in video_mux()
1148 btv->c.nr,input,mux); in video_mux()
1151 if(bttv_tvcards[btv->c.type].muxsel_hook) in video_mux()
1152 bttv_tvcards[btv->c.type].muxsel_hook (btv, input); in video_mux()
1162 audio_mux(struct bttv *btv, int input, int mute) in audio_mux() argument
1168 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, in audio_mux()
1169 bttv_tvcards[btv->c.type].gpiomask); in audio_mux()
1172 btv->mute = mute; in audio_mux()
1173 btv->audio = input; in audio_mux()
1176 mute = mute || (btv->opt_automute && !signal && !btv->radio_user); in audio_mux()
1179 gpio_val = bttv_tvcards[btv->c.type].gpiomute; in audio_mux()
1181 gpio_val = bttv_tvcards[btv->c.type].gpiomux[input]; in audio_mux()
1183 gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val); in audio_mux()
1185 bttv_gpio_tracking(btv, audio_modes[mute ? 4 : input]); in audio_mux()
1190 ctrl.value = btv->mute; in audio_mux()
1191 bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, &ctrl); in audio_mux()
1192 c = btv->i2c_msp34xx_client; in audio_mux()
1224 if (btv->c.type == BTTV_BOARD_VOODOOTV_200) in audio_mux()
1234 c = btv->i2c_tvaudio_client; in audio_mux()
1246 audio_mute(struct bttv *btv, int mute) in audio_mute() argument
1248 return audio_mux(btv, btv->audio, mute); in audio_mute()
1252 audio_input(struct bttv *btv, int input) in audio_input() argument
1254 return audio_mux(btv, input, btv->mute); in audio_input()
1288 set_tvnorm(struct bttv *btv, unsigned int norm) in set_tvnorm() argument
1298 if (btv->tvnorm < 0 || in set_tvnorm()
1299 btv->tvnorm >= BTTV_TVNORMS || in set_tvnorm()
1300 0 != memcmp(&bttv_tvnorms[btv->tvnorm].cropcap, in set_tvnorm()
1303 bttv_crop_reset(&btv->crop[0], norm); in set_tvnorm()
1304 btv->crop[1] = btv->crop[0]; /* current = default */ in set_tvnorm()
1306 if (0 == (btv->resources & VIDEO_RESOURCES)) { in set_tvnorm()
1307 btv->crop_start = tvnorm->cropcap.bounds.top in set_tvnorm()
1312 btv->tvnorm = norm; in set_tvnorm()
1320 bt848A_set_timing(btv); in set_tvnorm()
1322 switch (btv->c.type) { in set_tvnorm()
1325 bttv_tda9880_setnorm(btv,norm); in set_tvnorm()
1329 bttv_call_i2c_clients(btv, VIDIOC_S_STD, &id); in set_tvnorm()
1336 set_input(struct bttv *btv, unsigned int input, unsigned int norm) in set_input() argument
1340 btv->input = input; in set_input()
1342 spin_lock_irqsave(&btv->s_lock,flags); in set_input()
1343 if (btv->curr.frame_irq) { in set_input()
1345 btv->new_input = input; in set_input()
1347 video_mux(btv,input); in set_input()
1349 spin_unlock_irqrestore(&btv->s_lock,flags); in set_input()
1351 video_mux(btv,input); in set_input()
1353 audio_input(btv,(input == bttv_tvcards[btv->c.type].tuner ? in set_input()
1355 set_tvnorm(btv, norm); in set_input()
1358 static void init_irqreg(struct bttv *btv) in init_irqreg() argument
1363 if (bttv_tvcards[btv->c.type].no_video) { in init_irqreg()
1369 btwrite((btv->triton1) | in init_irqreg()
1370 (btv->gpioirq ? BT848_INT_GPINT : 0) | in init_irqreg()
1380 static void init_bt848(struct bttv *btv) in init_bt848() argument
1384 if (bttv_tvcards[btv->c.type].no_video) { in init_bt848()
1386 init_irqreg(btv); in init_bt848()
1403 val = btv->opt_chroma_agc ? BT848_SCLOOP_CAGC : 0; in init_bt848()
1409 btwrite(BT848_ADC_RESERVED | (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0), in init_bt848()
1415 if (btv->opt_lumafilter) { in init_bt848()
1423 bt848_bright(btv, btv->bright); in init_bt848()
1424 bt848_hue(btv, btv->hue); in init_bt848()
1425 bt848_contrast(btv, btv->contrast); in init_bt848()
1426 bt848_sat(btv, btv->saturation); in init_bt848()
1429 init_irqreg(btv); in init_bt848()
1432 static void bttv_reinit_bt848(struct bttv *btv) in bttv_reinit_bt848() argument
1437 printk(KERN_INFO "bttv%d: reset, reinitialize\n",btv->c.nr); in bttv_reinit_bt848()
1438 spin_lock_irqsave(&btv->s_lock,flags); in bttv_reinit_bt848()
1439 btv->errors=0; in bttv_reinit_bt848()
1440 bttv_set_dma(btv,0); in bttv_reinit_bt848()
1441 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_reinit_bt848()
1443 init_bt848(btv); in bttv_reinit_bt848()
1444 btv->pll.pll_current = -1; in bttv_reinit_bt848()
1445 set_input(btv, btv->input, btv->tvnorm); in bttv_reinit_bt848()
1452 struct bttv *btv = fh->btv; in bttv_g_ctrl() local
1456 c->value = btv->bright; in bttv_g_ctrl()
1459 c->value = btv->hue; in bttv_g_ctrl()
1462 c->value = btv->contrast; in bttv_g_ctrl()
1465 c->value = btv->saturation; in bttv_g_ctrl()
1473 bttv_call_i2c_clients(btv, VIDIOC_G_CTRL, c); in bttv_g_ctrl()
1477 c->value = btv->opt_chroma_agc; in bttv_g_ctrl()
1480 c->value = btv->opt_combfilter; in bttv_g_ctrl()
1483 c->value = btv->opt_lumafilter; in bttv_g_ctrl()
1486 c->value = btv->opt_automute; in bttv_g_ctrl()
1489 c->value = btv->opt_adc_crush; in bttv_g_ctrl()
1492 c->value = btv->opt_vcr_hack; in bttv_g_ctrl()
1495 c->value = btv->opt_whitecrush_upper; in bttv_g_ctrl()
1498 c->value = btv->opt_whitecrush_lower; in bttv_g_ctrl()
1501 c->value = btv->opt_uv_ratio; in bttv_g_ctrl()
1504 c->value = btv->opt_full_luma_range; in bttv_g_ctrl()
1507 c->value = btv->opt_coring; in bttv_g_ctrl()
1521 struct bttv *btv = fh->btv; in bttv_s_ctrl() local
1523 err = v4l2_prio_check(&btv->prio, &fh->prio); in bttv_s_ctrl()
1529 bt848_bright(btv, c->value); in bttv_s_ctrl()
1532 bt848_hue(btv, c->value); in bttv_s_ctrl()
1535 bt848_contrast(btv, c->value); in bttv_s_ctrl()
1538 bt848_sat(btv, c->value); in bttv_s_ctrl()
1541 audio_mute(btv, c->value); in bttv_s_ctrl()
1544 if (btv->volume_gpio) in bttv_s_ctrl()
1545 btv->volume_gpio(btv, c->value); in bttv_s_ctrl()
1547 bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, c); in bttv_s_ctrl()
1552 bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, c); in bttv_s_ctrl()
1556 btv->opt_chroma_agc = c->value; in bttv_s_ctrl()
1557 val = btv->opt_chroma_agc ? BT848_SCLOOP_CAGC : 0; in bttv_s_ctrl()
1562 btv->opt_combfilter = c->value; in bttv_s_ctrl()
1565 btv->opt_lumafilter = c->value; in bttv_s_ctrl()
1566 if (btv->opt_lumafilter) { in bttv_s_ctrl()
1575 btv->opt_automute = c->value; in bttv_s_ctrl()
1578 btv->opt_adc_crush = c->value; in bttv_s_ctrl()
1580 (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0), in bttv_s_ctrl()
1584 btv->opt_vcr_hack = c->value; in bttv_s_ctrl()
1587 btv->opt_whitecrush_upper = c->value; in bttv_s_ctrl()
1591 btv->opt_whitecrush_lower = c->value; in bttv_s_ctrl()
1595 btv->opt_uv_ratio = c->value; in bttv_s_ctrl()
1596 bt848_sat(btv, btv->saturation); in bttv_s_ctrl()
1599 btv->opt_full_luma_range = c->value; in bttv_s_ctrl()
1603 btv->opt_coring = c->value; in bttv_s_ctrl()
1614 void bttv_gpio_tracking(struct bttv *btv, char *comment) in bttv_gpio_tracking() argument
1620 btv->c.nr,outbits,data & outbits, data & ~outbits, comment); in bttv_gpio_tracking()
1623 static void bttv_field_count(struct bttv *btv) in bttv_field_count() argument
1627 if (btv->users) in bttv_field_count()
1636 btv->field_count = 0; in bttv_field_count()
1658 bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh, in bttv_switch_overlay() argument
1668 spin_lock_irqsave(&btv->s_lock,flags); in bttv_switch_overlay()
1669 old = btv->screen; in bttv_switch_overlay()
1670 btv->screen = new; in bttv_switch_overlay()
1671 btv->loop_irq |= 1; in bttv_switch_overlay()
1672 bttv_set_dma(btv, 0x03); in bttv_switch_overlay()
1673 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_switch_overlay()
1676 bttv_dma_free(&fh->cap,btv, old); in bttv_switch_overlay()
1680 free_btres(btv,fh,RESOURCE_OVERLAY); in bttv_switch_overlay()
1688 static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv, in bttv_prepare_buffer() argument
1712 mutex_lock(&btv->lock); in bttv_prepare_buffer()
1714 norm = btv->tvnorm; in bttv_prepare_buffer()
1718 if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) { in bttv_prepare_buffer()
1719 mutex_unlock(&btv->lock); in bttv_prepare_buffer()
1723 mutex_unlock(&btv->lock); in bttv_prepare_buffer()
1727 mutex_lock(&btv->lock); in bttv_prepare_buffer()
1729 norm = btv->tvnorm; in bttv_prepare_buffer()
1730 c = btv->crop[!!fh->do_crop]; in bttv_prepare_buffer()
1732 mutex_unlock(&btv->lock); in bttv_prepare_buffer()
1780 if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf))) in bttv_prepare_buffer()
1785 if (0 != (rc = bttv_buffer_risc(btv,buf))) in bttv_prepare_buffer()
1792 bttv_dma_free(q,btv,buf); in bttv_prepare_buffer()
1816 return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt, in buffer_prepare()
1825 struct bttv *btv = fh->btv; in buffer_queue() local
1828 list_add_tail(&buf->vb.queue,&btv->capture); in buffer_queue()
1829 if (!btv->curr.frame_irq) { in buffer_queue()
1830 btv->loop_irq |= 1; in buffer_queue()
1831 bttv_set_dma(btv, 0x03); in buffer_queue()
1840 bttv_dma_free(q,fh->btv,buf); in buffer_release()
1853 struct bttv *btv = fh->btv; in bttv_s_std() local
1857 err = v4l2_prio_check(&btv->prio, &fh->prio); in bttv_s_std()
1867 mutex_lock(&btv->lock); in bttv_s_std()
1868 set_tvnorm(btv, i); in bttv_s_std()
1869 mutex_unlock(&btv->lock); in bttv_s_std()
1877 struct bttv *btv = fh->btv; in bttv_querystd() local
1890 struct bttv *btv = fh->btv; in bttv_enum_input() local
1895 if (n >= bttv_tvcards[btv->c.type].video_inputs) in bttv_enum_input()
1904 if (i->index == bttv_tvcards[btv->c.type].tuner) { in bttv_enum_input()
1908 } else if (i->index == btv->svhs) { in bttv_enum_input()
1914 if (i->index == btv->input) { in bttv_enum_input()
1931 struct bttv *btv = fh->btv; in bttv_g_input() local
1933 *i = btv->input; in bttv_g_input()
1940 struct bttv *btv = fh->btv; in bttv_s_input() local
1944 err = v4l2_prio_check(&btv->prio, &fh->prio); in bttv_s_input()
1948 if (i > bttv_tvcards[btv->c.type].video_inputs) in bttv_s_input()
1951 mutex_lock(&btv->lock); in bttv_s_input()
1952 set_input(btv, i, btv->tvnorm); in bttv_s_input()
1953 mutex_unlock(&btv->lock); in bttv_s_input()
1961 struct bttv *btv = fh->btv; in bttv_s_tuner() local
1964 err = v4l2_prio_check(&btv->prio, &fh->prio); in bttv_s_tuner()
1968 if (UNSET == bttv_tvcards[btv->c.type].tuner) in bttv_s_tuner()
1974 mutex_lock(&btv->lock); in bttv_s_tuner()
1975 bttv_call_i2c_clients(btv, VIDIOC_S_TUNER, t); in bttv_s_tuner()
1977 if (btv->audio_mode_gpio) in bttv_s_tuner()
1978 btv->audio_mode_gpio(btv, t, 1); in bttv_s_tuner()
1980 mutex_unlock(&btv->lock); in bttv_s_tuner()
1989 struct bttv *btv = fh->btv; in bttv_g_frequency() local
1992 err = v4l2_prio_check(&btv->prio, &fh->prio); in bttv_g_frequency()
1996 f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; in bttv_g_frequency()
1997 f->frequency = btv->freq; in bttv_g_frequency()
2006 struct bttv *btv = fh->btv; in bttv_s_frequency() local
2009 err = v4l2_prio_check(&btv->prio, &fh->prio); in bttv_s_frequency()
2015 if (unlikely(f->type != (btv->radio_user in bttv_s_frequency()
2018 mutex_lock(&btv->lock); in bttv_s_frequency()
2019 btv->freq = f->frequency; in bttv_s_frequency()
2020 bttv_call_i2c_clients(btv, VIDIOC_S_FREQUENCY, f); in bttv_s_frequency()
2021 if (btv->has_matchbox && btv->radio_user) in bttv_s_frequency()
2022 tea5757_set_freq(btv, btv->freq); in bttv_s_frequency()
2023 mutex_unlock(&btv->lock); in bttv_s_frequency()
2030 struct bttv *btv = fh->btv; in bttv_log_status() local
2033 btv->c.nr, btv->c.nr); in bttv_log_status()
2034 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL); in bttv_log_status()
2036 btv->c.nr, btv->c.nr); in bttv_log_status()
2045 struct bttv *btv = fh->btv; in bttv_g_register() local
2065 struct bttv *btv = fh->btv; in bttv_s_register() local
2141 struct bttv *btv = fh->btv; in limit_scaled_size() local
2155 mutex_lock(&btv->lock); in limit_scaled_size()
2157 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in limit_scaled_size()
2160 c = &btv->crop[!!fh->do_crop]; in limit_scaled_size()
2165 && !locked_btres(btv, VIDEO_RESOURCES)) { in limit_scaled_size()
2178 if (btv->vbi_end > b->top) { in limit_scaled_size()
2179 max_height -= btv->vbi_end - b->top; in limit_scaled_size()
2186 if (btv->vbi_end > c->rect.top) in limit_scaled_size()
2215 if (btv->vbi_end > c->rect.top) { in limit_scaled_size()
2217 c->rect.top = btv->vbi_end; in limit_scaled_size()
2233 mutex_unlock(&btv->lock); in limit_scaled_size()
2265 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; in verify_window()
2311 static int setup_window(struct bttv_fh *fh, struct bttv *btv, in setup_window() argument
2341 if (NULL != btv->fbuf.base) in setup_window()
2342 n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, in setup_window()
2370 btv->init.ov.w.width = win->w.width; in setup_window()
2371 btv->init.ov.w.height = win->w.height; in setup_window()
2372 btv->init.ov.field = win->field; in setup_window()
2380 new->crop = btv->crop[!!fh->do_crop].rect; in setup_window()
2381 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in setup_window()
2382 retval = bttv_switch_overlay(btv,fh,new); in setup_window()
2484 struct bttv *btv = fh->btv; in bttv_try_fmt_vid_cap() local
2498 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2555 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_cap() local
2590 btv->init.fmt = fmt; in bttv_s_fmt_vid_cap()
2591 btv->init.width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2592 btv->init.height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2602 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_overlay() local
2609 return setup_window(fh, btv, &f->fmt.win, 1); in bttv_s_fmt_vid_overlay()
2644 struct bttv *btv = fh->btv; in bttv_querycap() local
2650 strlcpy(cap->card, btv->video_dev->name, sizeof(cap->card)); in bttv_querycap()
2652 "PCI:%s", pci_name(btv->c.pci)); in bttv_querycap()
2662 if (bttv_tvcards[btv->c.type].tuner != UNSET && in bttv_querycap()
2663 bttv_tvcards[btv->c.type].tuner != TUNER_ABSENT) in bttv_querycap()
2723 struct bttv *btv = fh->btv; in bttv_g_fbuf() local
2725 *fb = btv->fbuf; in bttv_g_fbuf()
2735 struct bttv *btv = fh->btv; in bttv_overlay() local
2741 if (NULL == btv->fbuf.base) in bttv_overlay()
2744 dprintk("bttv%d: overlay: !setup_ok\n", btv->c.nr); in bttv_overlay()
2749 if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY)) in bttv_overlay()
2754 fh->ov.tvnorm = btv->tvnorm; in bttv_overlay()
2756 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_overlay()
2757 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_overlay()
2763 retval = bttv_switch_overlay(btv, fh, new); in bttv_overlay()
2772 struct bttv *btv = fh->btv; in bttv_s_fbuf() local
2804 btv->fbuf.base = fb->base; in bttv_s_fbuf()
2805 btv->fbuf.fmt.width = fb->fmt.width; in bttv_s_fbuf()
2806 btv->fbuf.fmt.height = fb->fmt.height; in bttv_s_fbuf()
2808 btv->fbuf.fmt.bytesperline = fb->fmt.bytesperline; in bttv_s_fbuf()
2810 btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fmt->depth/8; in bttv_s_fbuf()
2814 btv->init.ovfmt = fmt; in bttv_s_fbuf()
2820 btv->init.ov.w.width = fb->fmt.width; in bttv_s_fbuf()
2821 btv->init.ov.w.height = fb->fmt.height; in bttv_s_fbuf()
2830 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_s_fbuf()
2831 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_s_fbuf()
2832 retval = bttv_switch_overlay(btv, fh, new); in bttv_s_fbuf()
2856 struct bttv *btv = fh->btv; in bttv_qbuf() local
2859 if (!check_alloc_btres(btv, fh, res)) in bttv_qbuf()
2876 struct bttv *btv = fh->btv; in bttv_streamon() local
2879 if (!check_alloc_btres(btv, fh, res)) in bttv_streamon()
2889 struct bttv *btv = fh->btv; in bttv_streamoff() local
2897 free_btres(btv, fh, res); in bttv_streamoff()
2905 struct bttv *btv = fh->btv; in bttv_queryctrl() local
2914 if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME)) in bttv_queryctrl()
2929 struct bttv *btv = fh->btv; in bttv_g_parm() local
2934 v4l2_video_std_construct(&s, bttv_tvnorms[btv->tvnorm].v4l2_id, in bttv_g_parm()
2935 bttv_tvnorms[btv->tvnorm].name); in bttv_g_parm()
2944 struct bttv *btv = fh->btv; in bttv_g_tuner() local
2946 if (UNSET == bttv_tvcards[btv->c.type].tuner) in bttv_g_tuner()
2951 mutex_lock(&btv->lock); in bttv_g_tuner()
2954 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); in bttv_g_tuner()
2961 if (btv->audio_mode_gpio) in bttv_g_tuner()
2962 btv->audio_mode_gpio(btv, t, 0); in bttv_g_tuner()
2964 mutex_unlock(&btv->lock); in bttv_g_tuner()
2971 struct bttv *btv = fh->btv; in bttv_g_priority() local
2973 *p = v4l2_prio_max(&btv->prio); in bttv_g_priority()
2982 struct bttv *btv = fh->btv; in bttv_s_priority() local
2984 return v4l2_prio_change(&btv->prio, &fh->prio, prio); in bttv_s_priority()
2991 struct bttv *btv = fh->btv; in bttv_cropcap() local
2997 *cap = bttv_tvnorms[btv->tvnorm].cropcap; in bttv_cropcap()
3005 struct bttv *btv = fh->btv; in bttv_g_crop() local
3015 crop->c = btv->crop[!!fh->do_crop].rect; in bttv_g_crop()
3023 struct bttv *btv = fh->btv; in bttv_s_crop() local
3036 retval = v4l2_prio_check(&btv->prio, &fh->prio); in bttv_s_crop()
3043 mutex_lock(&btv->lock); in bttv_s_crop()
3047 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { in bttv_s_crop()
3048 mutex_unlock(&btv->lock); in bttv_s_crop()
3052 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_s_crop()
3058 b_top = max(b->top, btv->vbi_end); in bttv_s_crop()
3060 mutex_unlock(&btv->lock); in bttv_s_crop()
3081 btv->crop[1] = c; in bttv_s_crop()
3083 mutex_unlock(&btv->lock); in bttv_s_crop()
3091 btv->init.width = c.min_scaled_width; in bttv_s_crop()
3094 btv->init.width = c.max_scaled_width; in bttv_s_crop()
3099 btv->init.height = c.min_scaled_height; in bttv_s_crop()
3102 btv->init.height = c.max_scaled_height; in bttv_s_crop()
3133 if (fh->btv->errors) in bttv_read()
3134 bttv_reinit_bt848(fh->btv); in bttv_read()
3136 fh->btv->c.nr,(int)count,v4l2_type_names[fh->type]); in bttv_read()
3140 if (!check_alloc_btres(fh->btv, fh, RESOURCE_VIDEO_READ)) { in bttv_read()
3147 free_btres(fh->btv, fh, RESOURCE_VIDEO_READ); in bttv_read()
3150 if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI)) in bttv_read()
3168 if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI)) in bttv_poll()
3183 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) in bttv_poll()
3215 struct bttv *btv = NULL; in bttv_open() local
3226 btv = &bttvs[i]; in bttv_open()
3232 btv = &bttvs[i]; in bttv_open()
3237 if (NULL == btv) { in bttv_open()
3243 btv->c.nr,v4l2_type_names[type]); in bttv_open()
3252 *fh = btv->init; in bttv_open()
3255 v4l2_prio_open(&btv->prio,&fh->prio); in bttv_open()
3258 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
3264 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
3269 set_tvnorm(btv,btv->tvnorm); in bttv_open()
3270 set_input(btv, btv->input, btv->tvnorm); in bttv_open()
3272 btv->users++; in bttv_open()
3288 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); in bttv_open()
3290 bttv_field_count(btv); in bttv_open()
3298 struct bttv *btv = fh->btv; in bttv_release() local
3302 bttv_switch_overlay(btv,fh,NULL); in bttv_release()
3307 free_btres(btv,fh,RESOURCE_VIDEO_STREAM); in bttv_release()
3314 free_btres(btv, fh, RESOURCE_VIDEO_READ); in bttv_release()
3320 free_btres(btv,fh,RESOURCE_VBI); in bttv_release()
3326 v4l2_prio_close(&btv->prio,&fh->prio); in bttv_release()
3330 btv->users--; in bttv_release()
3331 bttv_field_count(btv); in bttv_release()
3333 if (!btv->users) in bttv_release()
3334 audio_mute(btv, 1); in bttv_release()
3345 fh->btv->c.nr, v4l2_type_names[fh->type], in bttv_mmap()
3427 struct bttv *btv = NULL; in radio_open() local
3436 btv = &bttvs[i]; in radio_open()
3440 if (NULL == btv) { in radio_open()
3445 dprintk("bttv%d: open called (radio)\n",btv->c.nr); in radio_open()
3454 *fh = btv->init; in radio_open()
3455 v4l2_prio_open(&btv->prio, &fh->prio); in radio_open()
3457 mutex_lock(&btv->lock); in radio_open()
3459 btv->radio_user++; in radio_open()
3461 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL); in radio_open()
3462 audio_input(btv,TVAUDIO_INPUT_RADIO); in radio_open()
3464 mutex_unlock(&btv->lock); in radio_open()
3472 struct bttv *btv = fh->btv; in radio_release() local
3475 v4l2_prio_close(&btv->prio,&fh->prio); in radio_release()
3479 btv->radio_user--; in radio_release()
3481 bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); in radio_release()
3490 struct bttv *btv = fh->btv; in radio_querycap() local
3493 strlcpy(cap->card, btv->radio_dev->name, sizeof(cap->card)); in radio_querycap()
3494 sprintf(cap->bus_info, "PCI:%s", pci_name(btv->c.pci)); in radio_querycap()
3504 struct bttv *btv = fh->btv; in radio_g_tuner() local
3506 if (UNSET == bttv_tvcards[btv->c.type].tuner) in radio_g_tuner()
3510 mutex_lock(&btv->lock); in radio_g_tuner()
3515 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); in radio_g_tuner()
3517 if (btv->audio_mode_gpio) in radio_g_tuner()
3518 btv->audio_mode_gpio(btv, t, 0); in radio_g_tuner()
3520 mutex_unlock(&btv->lock); in radio_g_tuner()
3552 struct bttv *btv = fh->btv; in radio_s_tuner() local
3557 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); in radio_s_tuner()
3611 struct bttv *btv = fh->btv; in radio_read() local
3618 bttv_call_i2c_clients(btv, RDS_CMD_READ, &cmd); in radio_read()
3626 struct bttv *btv = fh->btv; in radio_poll() local
3631 bttv_call_i2c_clients(btv, RDS_CMD_POLL, &cmd); in radio_poll()
3709 static void bttv_risc_disasm(struct bttv *btv, in bttv_risc_disasm() argument
3715 btv->c.name, risc->cpu, (unsigned long)risc->dma); in bttv_risc_disasm()
3717 printk("%s: 0x%lx: ", btv->c.name, in bttv_risc_disasm()
3722 btv->c.name, (unsigned long)(risc->dma + ((i+j)<<2)), in bttv_risc_disasm()
3729 static void bttv_print_riscaddr(struct bttv *btv) in bttv_print_riscaddr() argument
3732 (unsigned long long)btv->main.dma); in bttv_print_riscaddr()
3734 btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0, in bttv_print_riscaddr()
3735 btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0); in bttv_print_riscaddr()
3737 btv->curr.top ? (unsigned long long)btv->curr.top->top.dma : 0, in bttv_print_riscaddr()
3738 btv->curr.bottom ? (unsigned long long)btv->curr.bottom->bottom.dma : 0); in bttv_print_riscaddr()
3740 btv->screen ? (unsigned long long)btv->screen->top.dma : 0, in bttv_print_riscaddr()
3741 btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0); in bttv_print_riscaddr()
3742 bttv_risc_disasm(btv, &btv->main); in bttv_print_riscaddr()
3783 static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc) in bttv_irq_debug_low_latency() argument
3786 btv->c.nr, in bttv_irq_debug_low_latency()
3787 (unsigned long)btv->main.dma, in bttv_irq_debug_low_latency()
3788 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]), in bttv_irq_debug_low_latency()
3789 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]), in bttv_irq_debug_low_latency()
3795 btv->c.nr); in bttv_irq_debug_low_latency()
3799 btv->c.nr); in bttv_irq_debug_low_latency()
3801 btv->c.nr); in bttv_irq_debug_low_latency()
3806 bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set) in bttv_irq_next_video() argument
3813 if (!list_empty(&btv->capture)) { in bttv_irq_next_video()
3815 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_next_video()
3823 (item->vb.queue.next != &btv->capture)) { in bttv_irq_next_video()
3841 if (NULL != btv->screen) { in bttv_irq_next_video()
3842 if (V4L2_FIELD_HAS_BOTH(btv->screen->vb.field)) { in bttv_irq_next_video()
3844 set->top = btv->screen; in bttv_irq_next_video()
3845 set->bottom = btv->screen; in bttv_irq_next_video()
3848 if (V4L2_FIELD_TOP == btv->screen->vb.field && in bttv_irq_next_video()
3850 set->top = btv->screen; in bttv_irq_next_video()
3852 if (V4L2_FIELD_BOTTOM == btv->screen->vb.field && in bttv_irq_next_video()
3854 set->bottom = btv->screen; in bttv_irq_next_video()
3860 btv->c.nr,set->top, set->bottom, in bttv_irq_next_video()
3861 btv->screen,set->frame_irq,set->top_irq); in bttv_irq_next_video()
3866 bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup, in bttv_irq_wakeup_video() argument
3876 printk("bttv%d: wakeup: both=%p\n",btv->c.nr,wakeup->top); in bttv_irq_wakeup_video()
3878 wakeup->top->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3885 printk("bttv%d: wakeup: top=%p\n",btv->c.nr,wakeup->top); in bttv_irq_wakeup_video()
3887 wakeup->top->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3893 printk("bttv%d: wakeup: bottom=%p\n",btv->c.nr,wakeup->bottom); in bttv_irq_wakeup_video()
3895 wakeup->bottom->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3903 bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, in bttv_irq_wakeup_vbi() argument
3913 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_vbi()
3920 struct bttv *btv = (struct bttv *)data; in bttv_irq_timeout() local
3928 btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total, in bttv_irq_timeout()
3934 spin_lock_irqsave(&btv->s_lock,flags); in bttv_irq_timeout()
3938 old = btv->curr; in bttv_irq_timeout()
3939 ovbi = btv->cvbi; in bttv_irq_timeout()
3940 btv->curr = new; in bttv_irq_timeout()
3941 btv->cvbi = NULL; in bttv_irq_timeout()
3942 btv->loop_irq = 0; in bttv_irq_timeout()
3943 bttv_buffer_activate_video(btv, &new); in bttv_irq_timeout()
3944 bttv_buffer_activate_vbi(btv, NULL); in bttv_irq_timeout()
3945 bttv_set_dma(btv, 0); in bttv_irq_timeout()
3948 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_ERROR); in bttv_irq_timeout()
3949 bttv_irq_wakeup_vbi(btv, ovbi, VIDEOBUF_ERROR); in bttv_irq_timeout()
3952 while (!list_empty(&btv->capture)) { in bttv_irq_timeout()
3953 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3958 while (!list_empty(&btv->vcapture)) { in bttv_irq_timeout()
3959 item = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3965 btv->errors++; in bttv_irq_timeout()
3966 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_irq_timeout()
3970 bttv_irq_wakeup_top(struct bttv *btv) in bttv_irq_wakeup_top() argument
3972 struct bttv_buffer *wakeup = btv->curr.top; in bttv_irq_wakeup_top()
3977 spin_lock(&btv->s_lock); in bttv_irq_wakeup_top()
3978 btv->curr.top_irq = 0; in bttv_irq_wakeup_top()
3979 btv->curr.top = NULL; in bttv_irq_wakeup_top()
3980 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); in bttv_irq_wakeup_top()
3983 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_top()
3986 spin_unlock(&btv->s_lock); in bttv_irq_wakeup_top()
3999 bttv_irq_switch_video(struct bttv *btv) in bttv_irq_switch_video() argument
4005 spin_lock(&btv->s_lock); in bttv_irq_switch_video()
4008 bttv_irq_next_video(btv, &new); in bttv_irq_switch_video()
4010 if ((btv->curr.top && is_active(&btv->curr.top->top, rc)) || in bttv_irq_switch_video()
4011 (btv->curr.bottom && is_active(&btv->curr.bottom->bottom, rc))) { in bttv_irq_switch_video()
4012 btv->framedrop++; in bttv_irq_switch_video()
4014 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_video()
4015 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
4020 old = btv->curr; in bttv_irq_switch_video()
4021 btv->curr = new; in bttv_irq_switch_video()
4022 btv->loop_irq &= ~1; in bttv_irq_switch_video()
4023 bttv_buffer_activate_video(btv, &new); in bttv_irq_switch_video()
4024 bttv_set_dma(btv, 0); in bttv_irq_switch_video()
4027 if (UNSET != btv->new_input) { in bttv_irq_switch_video()
4028 video_mux(btv,btv->new_input); in bttv_irq_switch_video()
4029 btv->new_input = UNSET; in bttv_irq_switch_video()
4033 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_DONE); in bttv_irq_switch_video()
4034 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
4038 bttv_irq_switch_vbi(struct bttv *btv) in bttv_irq_switch_vbi() argument
4044 spin_lock(&btv->s_lock); in bttv_irq_switch_vbi()
4046 if (!list_empty(&btv->vcapture)) in bttv_irq_switch_vbi()
4047 new = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_switch_vbi()
4048 old = btv->cvbi; in bttv_irq_switch_vbi()
4053 btv->framedrop++; in bttv_irq_switch_vbi()
4055 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_vbi()
4056 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
4061 btv->cvbi = new; in bttv_irq_switch_vbi()
4062 btv->loop_irq &= ~4; in bttv_irq_switch_vbi()
4063 bttv_buffer_activate_vbi(btv, new); in bttv_irq_switch_vbi()
4064 bttv_set_dma(btv, 0); in bttv_irq_switch_vbi()
4066 bttv_irq_wakeup_vbi(btv, old, VIDEOBUF_DONE); in bttv_irq_switch_vbi()
4067 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
4075 struct bttv *btv; in bttv_irq() local
4078 btv=(struct bttv *)dev_id; in bttv_irq()
4080 if (btv->custom_irq) in bttv_irq()
4081 handled = btv->custom_irq(btv); in bttv_irq()
4099 btv->c.nr, count, btv->field_count, in bttv_irq()
4115 btv->field_count++; in bttv_irq()
4117 if ((astat & BT848_INT_GPINT) && btv->remote) { in bttv_irq()
4118 wake_up(&btv->gpioq); in bttv_irq()
4119 bttv_input_irq(btv); in bttv_irq()
4123 btv->i2c_done = stat; in bttv_irq()
4124 wake_up(&btv->i2c_queue); in bttv_irq()
4128 bttv_irq_switch_vbi(btv); in bttv_irq()
4131 bttv_irq_wakeup_top(btv); in bttv_irq()
4134 bttv_irq_switch_video(btv); in bttv_irq()
4136 if ((astat & BT848_INT_HLOCK) && btv->opt_automute) in bttv_irq()
4137 audio_mute(btv, btv->mute); /* trigger automute */ in bttv_irq()
4140 printk(KERN_INFO "bttv%d: %s%s @ %08x,",btv->c.nr, in bttv_irq()
4147 bttv_print_riscaddr(btv); in bttv_irq()
4151 btv->c.nr,btread(BT848_RISC_COUNT)); in bttv_irq()
4153 bttv_print_riscaddr(btv); in bttv_irq()
4163 "bttv%d: IRQ lockup, cleared int mask [", btv->c.nr); in bttv_irq()
4166 "bttv%d: IRQ lockup, clearing GPINT from int mask [", btv->c.nr); in bttv_irq()
4177 btv->irq_total++; in bttv_irq()
4179 btv->irq_me++; in bttv_irq()
4187 static struct video_device *vdev_init(struct bttv *btv, in vdev_init() argument
4198 vfd->parent = &btv->c.pci->dev; in vdev_init()
4202 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", in vdev_init()
4203 type_name, bttv_tvcards[btv->c.type].name); in vdev_init()
4207 static void bttv_unregister_video(struct bttv *btv) in bttv_unregister_video() argument
4209 if (btv->video_dev) { in bttv_unregister_video()
4210 if (-1 != btv->video_dev->minor) in bttv_unregister_video()
4211 video_unregister_device(btv->video_dev); in bttv_unregister_video()
4213 video_device_release(btv->video_dev); in bttv_unregister_video()
4214 btv->video_dev = NULL; in bttv_unregister_video()
4216 if (btv->vbi_dev) { in bttv_unregister_video()
4217 if (-1 != btv->vbi_dev->minor) in bttv_unregister_video()
4218 video_unregister_device(btv->vbi_dev); in bttv_unregister_video()
4220 video_device_release(btv->vbi_dev); in bttv_unregister_video()
4221 btv->vbi_dev = NULL; in bttv_unregister_video()
4223 if (btv->radio_dev) { in bttv_unregister_video()
4224 if (-1 != btv->radio_dev->minor) in bttv_unregister_video()
4225 video_unregister_device(btv->radio_dev); in bttv_unregister_video()
4227 video_device_release(btv->radio_dev); in bttv_unregister_video()
4228 btv->radio_dev = NULL; in bttv_unregister_video()
4233 static int __devinit bttv_register_video(struct bttv *btv) in bttv_register_video() argument
4239 btv->video_dev = vdev_init(btv, &bttv_video_template, "video"); in bttv_register_video()
4241 if (NULL == btv->video_dev) in bttv_register_video()
4243 if (video_register_device(btv->video_dev, VFL_TYPE_GRABBER, in bttv_register_video()
4244 video_nr[btv->c.nr]) < 0) in bttv_register_video()
4247 btv->c.nr, btv->video_dev->num); in bttv_register_video()
4248 if (device_create_file(&btv->video_dev->dev, in bttv_register_video()
4251 "failed\n", btv->c.nr); in bttv_register_video()
4256 btv->vbi_dev = vdev_init(btv, &bttv_video_template, "vbi"); in bttv_register_video()
4258 if (NULL == btv->vbi_dev) in bttv_register_video()
4260 if (video_register_device(btv->vbi_dev, VFL_TYPE_VBI, in bttv_register_video()
4261 vbi_nr[btv->c.nr]) < 0) in bttv_register_video()
4264 btv->c.nr, btv->vbi_dev->num); in bttv_register_video()
4266 if (!btv->has_radio) in bttv_register_video()
4269 btv->radio_dev = vdev_init(btv, &radio_template, "radio"); in bttv_register_video()
4270 if (NULL == btv->radio_dev) in bttv_register_video()
4272 if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO, in bttv_register_video()
4273 radio_nr[btv->c.nr]) < 0) in bttv_register_video()
4276 btv->c.nr, btv->radio_dev->num); in bttv_register_video()
4282 bttv_unregister_video(btv); in bttv_register_video()
4305 struct bttv *btv; in bttv_probe() local
4310 btv=&bttvs[bttv_num]; in bttv_probe()
4311 memset(btv,0,sizeof(*btv)); in bttv_probe()
4312 btv->c.nr = bttv_num; in bttv_probe()
4313 sprintf(btv->c.name,"bttv%d",btv->c.nr); in bttv_probe()
4316 mutex_init(&btv->lock); in bttv_probe()
4317 spin_lock_init(&btv->s_lock); in bttv_probe()
4318 spin_lock_init(&btv->gpio_lock); in bttv_probe()
4319 init_waitqueue_head(&btv->gpioq); in bttv_probe()
4320 init_waitqueue_head(&btv->i2c_queue); in bttv_probe()
4321 INIT_LIST_HEAD(&btv->c.subs); in bttv_probe()
4322 INIT_LIST_HEAD(&btv->capture); in bttv_probe()
4323 INIT_LIST_HEAD(&btv->vcapture); in bttv_probe()
4324 v4l2_prio_init(&btv->prio); in bttv_probe()
4326 init_timer(&btv->timeout); in bttv_probe()
4327 btv->timeout.function = bttv_irq_timeout; in bttv_probe()
4328 btv->timeout.data = (unsigned long)btv; in bttv_probe()
4330 btv->i2c_rc = -1; in bttv_probe()
4331 btv->tuner_type = UNSET; in bttv_probe()
4332 btv->new_input = UNSET; in bttv_probe()
4333 btv->has_radio=radio[btv->c.nr]; in bttv_probe()
4336 btv->c.pci = dev; in bttv_probe()
4337 btv->id = dev->device; in bttv_probe()
4340 btv->c.nr); in bttv_probe()
4345 btv->c.nr); in bttv_probe()
4350 btv->c.name)) { in bttv_probe()
4352 btv->c.nr, in bttv_probe()
4358 pci_set_drvdata(dev,btv); in bttv_probe()
4360 pci_read_config_byte(dev, PCI_CLASS_REVISION, &btv->revision); in bttv_probe()
4363 bttv_num,btv->id, btv->revision, pci_name(dev)); in bttv_probe()
4365 btv->c.pci->irq, lat, in bttv_probe()
4369 btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000); in bttv_probe()
4370 if (NULL == btv->bt848_mmio) { in bttv_probe()
4371 printk("bttv%d: ioremap() failed\n", btv->c.nr); in bttv_probe()
4377 bttv_idcard(btv); in bttv_probe()
4381 result = request_irq(btv->c.pci->irq, bttv_irq, in bttv_probe()
4382 IRQF_SHARED | IRQF_DISABLED,btv->c.name,(void *)btv); in bttv_probe()
4385 bttv_num,btv->c.pci->irq); in bttv_probe()
4389 if (0 != bttv_handle_chipset(btv)) { in bttv_probe()
4395 btv->opt_combfilter = combfilter; in bttv_probe()
4396 btv->opt_lumafilter = lumafilter; in bttv_probe()
4397 btv->opt_automute = automute; in bttv_probe()
4398 btv->opt_chroma_agc = chroma_agc; in bttv_probe()
4399 btv->opt_adc_crush = adc_crush; in bttv_probe()
4400 btv->opt_vcr_hack = vcr_hack; in bttv_probe()
4401 btv->opt_whitecrush_upper = whitecrush_upper; in bttv_probe()
4402 btv->opt_whitecrush_lower = whitecrush_lower; in bttv_probe()
4403 btv->opt_uv_ratio = uv_ratio; in bttv_probe()
4404 btv->opt_full_luma_range = full_luma_range; in bttv_probe()
4405 btv->opt_coring = coring; in bttv_probe()
4408 btv->init.btv = btv; in bttv_probe()
4409 btv->init.ov.w.width = 320; in bttv_probe()
4410 btv->init.ov.w.height = 240; in bttv_probe()
4411 btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); in bttv_probe()
4412 btv->init.width = 320; in bttv_probe()
4413 btv->init.height = 240; in bttv_probe()
4414 btv->input = 0; in bttv_probe()
4418 bttv_gpio_tracking(btv,"pre-init"); in bttv_probe()
4420 bttv_risc_init_main(btv); in bttv_probe()
4421 init_bt848(btv); in bttv_probe()
4427 bttv_gpio_tracking(btv,"init"); in bttv_probe()
4430 bttv_init_card1(btv); in bttv_probe()
4433 init_bttv_i2c(btv); in bttv_probe()
4436 bttv_init_card2(btv); in bttv_probe()
4437 init_irqreg(btv); in bttv_probe()
4440 if (!bttv_tvcards[btv->c.type].no_video) { in bttv_probe()
4441 bttv_register_video(btv); in bttv_probe()
4442 bt848_bright(btv,32768); in bttv_probe()
4443 bt848_contrast(btv,32768); in bttv_probe()
4444 bt848_hue(btv,32768); in bttv_probe()
4445 bt848_sat(btv,32768); in bttv_probe()
4446 audio_mute(btv, 1); in bttv_probe()
4447 set_input(btv, 0, btv->tvnorm); in bttv_probe()
4448 bttv_crop_reset(&btv->crop[0], btv->tvnorm); in bttv_probe()
4449 btv->crop[1] = btv->crop[0]; /* current = default */ in bttv_probe()
4450 disclaim_vbi_lines(btv); in bttv_probe()
4451 disclaim_video_lines(btv); in bttv_probe()
4455 if (bttv_tvcards[btv->c.type].has_dvb) { in bttv_probe()
4456 bttv_sub_add_device(&btv->c, "dvb"); in bttv_probe()
4457 request_modules(btv); in bttv_probe()
4460 bttv_input_init(btv); in bttv_probe()
4467 free_irq(btv->c.pci->irq,btv); in bttv_probe()
4470 if (btv->bt848_mmio) in bttv_probe()
4471 iounmap(btv->bt848_mmio); in bttv_probe()
4472 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_probe()
4473 pci_resource_len(btv->c.pci,0)); in bttv_probe()
4480 struct bttv *btv = pci_get_drvdata(pci_dev); in bttv_remove() local
4483 printk("bttv%d: unloading\n",btv->c.nr); in bttv_remove()
4491 bttv_gpio_tracking(btv,"cleanup"); in bttv_remove()
4494 btv->shutdown=1; in bttv_remove()
4495 wake_up(&btv->gpioq); in bttv_remove()
4496 bttv_input_fini(btv); in bttv_remove()
4497 bttv_sub_del_devices(&btv->c); in bttv_remove()
4500 fini_bttv_i2c(btv); in bttv_remove()
4503 bttv_unregister_video(btv); in bttv_remove()
4506 btcx_riscmem_free(btv->c.pci,&btv->main); in bttv_remove()
4509 free_irq(btv->c.pci->irq,btv); in bttv_remove()
4510 iounmap(btv->bt848_mmio); in bttv_remove()
4511 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_remove()
4512 pci_resource_len(btv->c.pci,0)); in bttv_remove()
4521 struct bttv *btv = pci_get_drvdata(pci_dev); in bttv_suspend() local
4525 dprintk("bttv%d: suspend %d\n", btv->c.nr, state.event); in bttv_suspend()
4528 spin_lock_irqsave(&btv->s_lock,flags); in bttv_suspend()
4530 btv->state.video = btv->curr; in bttv_suspend()
4531 btv->state.vbi = btv->cvbi; in bttv_suspend()
4532 btv->state.loop_irq = btv->loop_irq; in bttv_suspend()
4533 btv->curr = idle; in bttv_suspend()
4534 btv->loop_irq = 0; in bttv_suspend()
4535 bttv_buffer_activate_video(btv, &idle); in bttv_suspend()
4536 bttv_buffer_activate_vbi(btv, NULL); in bttv_suspend()
4537 bttv_set_dma(btv, 0); in bttv_suspend()
4539 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_suspend()
4542 btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN); in bttv_suspend()
4543 btv->state.gpio_data = gpio_read(); in bttv_suspend()
4549 btv->state.disabled = 1; in bttv_suspend()
4556 struct bttv *btv = pci_get_drvdata(pci_dev); in bttv_resume() local
4560 dprintk("bttv%d: resume\n", btv->c.nr); in bttv_resume()
4563 if (btv->state.disabled) { in bttv_resume()
4567 btv->c.nr); in bttv_resume()
4570 btv->state.disabled = 0; in bttv_resume()
4576 btv->c.nr); in bttv_resume()
4577 btv->state.disabled = 1; in bttv_resume()
4584 bttv_reinit_bt848(btv); in bttv_resume()
4585 gpio_inout(0xffffff, btv->state.gpio_enable); in bttv_resume()
4586 gpio_write(btv->state.gpio_data); in bttv_resume()
4589 spin_lock_irqsave(&btv->s_lock,flags); in bttv_resume()
4590 btv->curr = btv->state.video; in bttv_resume()
4591 btv->cvbi = btv->state.vbi; in bttv_resume()
4592 btv->loop_irq = btv->state.loop_irq; in bttv_resume()
4593 bttv_buffer_activate_video(btv, &btv->curr); in bttv_resume()
4594 bttv_buffer_activate_vbi(btv, btv->cvbi); in bttv_resume()
4595 bttv_set_dma(btv, 0); in bttv_resume()
4596 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_resume()