Lines Matching refs:fh
652 int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit) in check_alloc_btres_lock() argument
656 if (fh->resources & bit) in check_alloc_btres_lock()
673 __s32 top = btv->crop[!!fh->do_crop].rect.top; in check_alloc_btres_lock()
682 __s32 end = fh->vbi_fmt.end; in check_alloc_btres_lock()
692 fh->resources |= bit; in check_alloc_btres_lock()
701 int check_btres(struct bttv_fh *fh, int bit) in check_btres() argument
703 return (fh->resources & bit); in check_btres()
742 void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits) in free_btres_lock() argument
744 if ((fh->resources & bits) != bits) { in free_btres_lock()
748 fh->resources &= ~bits; in free_btres_lock()
775 unsigned char fl, fh, fi; in set_pll_freq() local
785 fh=fout/fin; in set_pll_freq()
791 btwrite(fh, BT848_PLL_F_HI); in set_pll_freq()
1498 bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh, in bttv_switch_overlay() argument
1516 bttv_dma_free(&fh->cap,btv, old); in bttv_switch_overlay()
1520 free_btres_lock(btv,fh,RESOURCE_OVERLAY); in bttv_switch_overlay()
1534 struct bttv_fh *fh = q->priv_data; in bttv_prepare_buffer() local
1564 c = btv->crop[!!fh->do_crop]; in bttv_prepare_buffer()
1631 struct bttv_fh *fh = q->priv_data; in buffer_setup() local
1633 *size = fh->fmt->depth*fh->width*fh->height >> 3; in buffer_setup()
1646 struct bttv_fh *fh = q->priv_data; in buffer_prepare() local
1648 return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt, in buffer_prepare()
1649 fh->width, fh->height, field); in buffer_prepare()
1656 struct bttv_fh *fh = q->priv_data; in buffer_queue() local
1657 struct bttv *btv = fh->btv; in buffer_queue()
1670 struct bttv_fh *fh = q->priv_data; in buffer_release() local
1672 bttv_dma_free(q,fh->btv,buf); in buffer_release()
1695 struct bttv_fh *fh = priv; in bttv_s_std() local
1696 struct bttv *btv = fh->btv; in bttv_s_std()
1711 struct bttv_fh *fh = priv; in bttv_g_std() local
1712 struct bttv *btv = fh->btv; in bttv_g_std()
1720 struct bttv_fh *fh = f; in bttv_querystd() local
1721 struct bttv *btv = fh->btv; in bttv_querystd()
1733 struct bttv_fh *fh = priv; in bttv_enum_input() local
1734 struct bttv *btv = fh->btv; in bttv_enum_input()
1766 struct bttv_fh *fh = priv; in bttv_g_input() local
1767 struct bttv *btv = fh->btv; in bttv_g_input()
1776 struct bttv_fh *fh = priv; in bttv_s_input() local
1777 struct bttv *btv = fh->btv; in bttv_s_input()
1789 struct bttv_fh *fh = priv; in bttv_s_tuner() local
1790 struct bttv *btv = fh->btv; in bttv_s_tuner()
1808 struct bttv_fh *fh = priv; in bttv_g_frequency() local
1809 struct bttv *btv = fh->btv; in bttv_g_frequency()
1845 struct bttv_fh *fh = priv; in bttv_s_frequency() local
1846 struct bttv *btv = fh->btv; in bttv_s_frequency()
1858 struct bttv_fh *fh = f; in bttv_log_status() local
1859 struct bttv *btv = fh->btv; in bttv_log_status()
1870 struct bttv_fh *fh = f; in bttv_g_register() local
1871 struct bttv *btv = fh->btv; in bttv_g_register()
1884 struct bttv_fh *fh = f; in bttv_s_register() local
1885 struct bttv *btv = fh->btv; in bttv_s_register()
1945 limit_scaled_size_lock (struct bttv_fh * fh, in limit_scaled_size_lock() argument
1954 struct bttv *btv = fh->btv; in limit_scaled_size_lock()
1972 c = &btv->crop[!!fh->do_crop]; in limit_scaled_size_lock()
1974 if (fh->do_crop in limit_scaled_size_lock()
2056 verify_window_lock(struct bttv_fh *fh, struct v4l2_window *win, in verify_window_lock() argument
2085 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; in verify_window_lock()
2092 if (NULL == fh->ovfmt) in verify_window_lock()
2096 switch (fh->ovfmt->depth) { in verify_window_lock()
2113 return limit_scaled_size_lock(fh, &win->w.width, &win->w.height, in verify_window_lock()
2119 static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, in setup_window_lock() argument
2125 if (NULL == fh->ovfmt) in setup_window_lock()
2127 if (!(fh->ovfmt->flags & FORMAT_FLAGS_PACKED)) in setup_window_lock()
2129 retval = verify_window_lock(fh, win, in setup_window_lock()
2152 switch (fh->ovfmt->depth) { in setup_window_lock()
2167 kfree(fh->ov.clips); in setup_window_lock()
2168 fh->ov.clips = clips; in setup_window_lock()
2169 fh->ov.nclips = n; in setup_window_lock()
2171 fh->ov.w = win->w; in setup_window_lock()
2172 fh->ov.field = win->field; in setup_window_lock()
2173 fh->ov.setup_ok = 1; in setup_window_lock()
2181 if (check_btres(fh, RESOURCE_OVERLAY)) { 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()
2194 static struct videobuf_queue* bttv_queue(struct bttv_fh *fh) in bttv_queue() argument
2198 switch (fh->type) { in bttv_queue()
2200 q = &fh->cap; in bttv_queue()
2203 q = &fh->vbi; in bttv_queue()
2211 static int bttv_resource(struct bttv_fh *fh) in bttv_resource() argument
2215 switch (fh->type) { in bttv_resource()
2228 static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type) in bttv_switch_type() argument
2230 struct videobuf_queue *q = bttv_queue(fh); in bttv_switch_type()
2231 int res = bttv_resource(fh); in bttv_switch_type()
2233 if (check_btres(fh,res)) in bttv_switch_type()
2237 fh->type = type; in bttv_switch_type()
2262 struct bttv_fh *fh = priv; in bttv_g_fmt_vid_cap() local
2264 pix_format_set_size(&f->fmt.pix, fh->fmt, in bttv_g_fmt_vid_cap()
2265 fh->width, fh->height); in bttv_g_fmt_vid_cap()
2266 f->fmt.pix.field = fh->cap.field; in bttv_g_fmt_vid_cap()
2267 f->fmt.pix.pixelformat = fh->fmt->fourcc; in bttv_g_fmt_vid_cap()
2276 struct bttv_fh *fh = priv; in bttv_g_fmt_vid_overlay() local
2278 f->fmt.win.w = fh->ov.w; in bttv_g_fmt_vid_overlay()
2279 f->fmt.win.field = fh->ov.field; in bttv_g_fmt_vid_overlay()
2301 struct bttv_fh *fh = priv; in bttv_try_fmt_vid_cap() local
2302 struct bttv *btv = fh->btv; in bttv_try_fmt_vid_cap()
2329 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2340 rc = limit_scaled_size_lock(fh, &width, &height, field, in bttv_try_fmt_vid_cap()
2358 struct bttv_fh *fh = priv; in bttv_try_fmt_vid_overlay() local
2360 verify_window_lock(fh, &f->fmt.win, in bttv_try_fmt_vid_overlay()
2371 struct bttv_fh *fh = priv; in bttv_s_fmt_vid_cap() local
2372 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_cap()
2377 retval = bttv_switch_type(fh, f->type); in bttv_s_fmt_vid_cap()
2391 retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field, in bttv_s_fmt_vid_cap()
2401 fh->fmt = fmt; in bttv_s_fmt_vid_cap()
2402 fh->cap.field = f->fmt.pix.field; in bttv_s_fmt_vid_cap()
2403 fh->cap.last = V4L2_FIELD_NONE; in bttv_s_fmt_vid_cap()
2404 fh->width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2405 fh->height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2416 struct bttv_fh *fh = priv; in bttv_s_fmt_vid_overlay() local
2417 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_overlay()
2424 return setup_window_lock(fh, btv, &f->fmt.win, 1); in bttv_s_fmt_vid_overlay()
2430 struct bttv_fh *fh = priv; in bttv_querycap() local
2431 struct bttv *btv = fh->btv; in bttv_querycap()
2514 struct bttv_fh *fh = f; in bttv_g_fbuf() local
2515 struct bttv *btv = fh->btv; in bttv_g_fbuf()
2520 if (fh->ovfmt) in bttv_g_fbuf()
2521 fb->fmt.pixelformat = fh->ovfmt->fourcc; in bttv_g_fbuf()
2527 struct bttv_fh *fh = f; in bttv_overlay() local
2528 struct bttv *btv = fh->btv; in bttv_overlay()
2537 if (unlikely(!fh->ov.setup_ok)) { 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()
2565 struct bttv_fh *fh = f; in bttv_s_fbuf() local
2566 struct bttv *btv = fh->btv; in bttv_s_fbuf()
2586 retval = limit_scaled_size_lock(fh, &width, &height, in bttv_s_fbuf()
2606 fh->ovfmt = fmt; in bttv_s_fbuf()
2609 fh->ov.w.left = 0; in bttv_s_fbuf()
2610 fh->ov.w.top = 0; in bttv_s_fbuf()
2611 fh->ov.w.width = fb->fmt.width; in bttv_s_fbuf()
2612 fh->ov.w.height = fb->fmt.height; in bttv_s_fbuf()
2616 kfree(fh->ov.clips); in bttv_s_fbuf()
2617 fh->ov.clips = NULL; in bttv_s_fbuf()
2618 fh->ov.nclips = 0; in bttv_s_fbuf()
2620 if (check_btres(fh, RESOURCE_OVERLAY)) { 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()
2635 struct bttv_fh *fh = priv; in bttv_reqbufs() local
2636 return videobuf_reqbufs(bttv_queue(fh), p); in bttv_reqbufs()
2642 struct bttv_fh *fh = priv; in bttv_querybuf() local
2643 return videobuf_querybuf(bttv_queue(fh), b); in bttv_querybuf()
2648 struct bttv_fh *fh = priv; in bttv_qbuf() local
2649 struct bttv *btv = fh->btv; in bttv_qbuf()
2650 int res = bttv_resource(fh); in bttv_qbuf()
2652 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_qbuf()
2655 return videobuf_qbuf(bttv_queue(fh), b); in bttv_qbuf()
2660 struct bttv_fh *fh = priv; in bttv_dqbuf() local
2661 return videobuf_dqbuf(bttv_queue(fh), b, in bttv_dqbuf()
2668 struct bttv_fh *fh = priv; in bttv_streamon() local
2669 struct bttv *btv = fh->btv; in bttv_streamon()
2670 int res = bttv_resource(fh); in bttv_streamon()
2672 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_streamon()
2674 return videobuf_streamon(bttv_queue(fh)); in bttv_streamon()
2681 struct bttv_fh *fh = priv; in bttv_streamoff() local
2682 struct bttv *btv = fh->btv; in bttv_streamoff()
2684 int res = bttv_resource(fh); in bttv_streamoff()
2687 retval = videobuf_streamoff(bttv_queue(fh)); in bttv_streamoff()
2690 free_btres_lock(btv, fh, res); in bttv_streamoff()
2697 struct bttv_fh *fh = f; in bttv_g_parm() local
2698 struct bttv *btv = fh->btv; in bttv_g_parm()
2712 struct bttv_fh *fh = priv; in bttv_g_tuner() local
2713 struct bttv *btv = fh->btv; in bttv_g_tuner()
2735 struct bttv_fh *fh = priv; in bttv_g_pixelaspect() local
2736 struct bttv *btv = fh->btv; in bttv_g_pixelaspect()
2748 struct bttv_fh *fh = f; in bttv_g_selection() local
2749 struct bttv *btv = fh->btv; in bttv_g_selection()
2762 sel->r = btv->crop[!!fh->do_crop].rect; in bttv_g_selection()
2779 struct bttv_fh *fh = f; in bttv_s_selection() local
2780 struct bttv *btv = fh->btv; in bttv_s_selection()
2801 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { in bttv_s_selection()
2837 fh->do_crop = 1; in bttv_s_selection()
2839 if (fh->width < c.min_scaled_width) { in bttv_s_selection()
2840 fh->width = c.min_scaled_width; in bttv_s_selection()
2842 } else if (fh->width > c.max_scaled_width) { in bttv_s_selection()
2843 fh->width = c.max_scaled_width; in bttv_s_selection()
2847 if (fh->height < c.min_scaled_height) { in bttv_s_selection()
2848 fh->height = c.min_scaled_height; in bttv_s_selection()
2850 } else if (fh->height > c.max_scaled_height) { in bttv_s_selection()
2851 fh->height = c.max_scaled_height; in bttv_s_selection()
2861 struct bttv_fh *fh = file->private_data; in bttv_read() local
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()
2869 switch (fh->type) { in bttv_read()
2871 if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) { in bttv_read()
2876 retval = videobuf_read_one(&fh->cap, data, count, ppos, 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()
2883 retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1, in bttv_read()
2894 struct bttv_fh *fh = file->private_data; in bttv_poll() local
2900 if (v4l2_event_pending(&fh->fh)) in bttv_poll()
2903 poll_wait(file, &fh->fh.wait, wait); in bttv_poll()
2908 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { in bttv_poll()
2909 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_poll()
2911 return rc | videobuf_poll_stream(file, &fh->vbi, wait); in bttv_poll()
2914 if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { in bttv_poll()
2916 if (list_empty(&fh->cap.stream)) in bttv_poll()
2918 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); in bttv_poll()
2921 if (NULL == fh->cap.read_buf) { in bttv_poll()
2923 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) in bttv_poll()
2925 fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize); in bttv_poll()
2926 if (NULL == fh->cap.read_buf) in bttv_poll()
2928 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; in bttv_poll()
2929 field = videobuf_next_field(&fh->cap); in bttv_poll()
2930 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { in bttv_poll()
2931 kfree (fh->cap.read_buf); in bttv_poll()
2932 fh->cap.read_buf = NULL; in bttv_poll()
2935 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); in bttv_poll()
2936 fh->cap.read_off = 0; in bttv_poll()
2938 buf = (struct bttv_buffer*)fh->cap.read_buf; in bttv_poll()
2952 struct bttv_fh *fh; in bttv_open() local
2970 fh = kmalloc(sizeof(*fh), GFP_KERNEL); in bttv_open()
2971 if (unlikely(!fh)) in bttv_open()
2974 file->private_data = fh; in bttv_open()
2976 *fh = btv->init; in bttv_open()
2977 v4l2_fh_init(&fh->fh, vdev); in bttv_open()
2979 fh->type = type; in bttv_open()
2980 fh->ov.setup_ok = 0; in bttv_open()
2982 videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, in bttv_open()
2987 fh, &btv->lock); in bttv_open()
2988 videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, in bttv_open()
2993 fh, &btv->lock); in bttv_open()
3007 fh->do_crop = !reset_crop; /* module parameter */ in bttv_open()
3012 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); in bttv_open()
3015 v4l2_fh_add(&fh->fh); in bttv_open()
3021 struct bttv_fh *fh = file->private_data; in bttv_release() local
3022 struct bttv *btv = fh->btv; in bttv_release()
3025 if (check_btres(fh, RESOURCE_OVERLAY)) in bttv_release()
3026 bttv_switch_overlay(btv,fh,NULL); in bttv_release()
3029 if (check_btres(fh, RESOURCE_VIDEO_STREAM)) { in bttv_release()
3030 videobuf_streamoff(&fh->cap); in bttv_release()
3031 free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM); in bttv_release()
3033 if (fh->cap.read_buf) { in bttv_release()
3034 buffer_release(&fh->cap,fh->cap.read_buf); in bttv_release()
3035 kfree(fh->cap.read_buf); in bttv_release()
3037 if (check_btres(fh, RESOURCE_VIDEO_READ)) { in bttv_release()
3038 free_btres_lock(btv, fh, RESOURCE_VIDEO_READ); in bttv_release()
3042 if (check_btres(fh, RESOURCE_VBI)) { in bttv_release()
3043 videobuf_stop(&fh->vbi); in bttv_release()
3044 free_btres_lock(btv,fh,RESOURCE_VBI); in bttv_release()
3049 videobuf_mmap_free(&fh->cap); in bttv_release()
3050 videobuf_mmap_free(&fh->vbi); in bttv_release()
3059 v4l2_fh_del(&fh->fh); in bttv_release()
3060 v4l2_fh_exit(&fh->fh); in bttv_release()
3061 kfree(fh); in bttv_release()
3068 struct bttv_fh *fh = file->private_data; in bttv_mmap() local
3071 fh->btv->c.nr, v4l2_type_names[fh->type], in bttv_mmap()
3073 return videobuf_mmap_mapper(bttv_queue(fh),vma); in bttv_mmap()
3145 struct bttv_fh *fh; in radio_open() local
3152 fh = kmalloc(sizeof(*fh), GFP_KERNEL); in radio_open()
3153 if (unlikely(!fh)) in radio_open()
3155 file->private_data = fh; in radio_open()
3156 *fh = btv->init; in radio_open()
3157 v4l2_fh_init(&fh->fh, vdev); in radio_open()
3162 v4l2_fh_add(&fh->fh); in radio_open()
3169 struct bttv_fh *fh = file->private_data; in radio_release() local
3170 struct bttv *btv = fh->btv; in radio_release()
3174 v4l2_fh_del(&fh->fh); in radio_release()
3175 v4l2_fh_exit(&fh->fh); in radio_release()
3176 kfree(fh); in radio_release()
3189 struct bttv_fh *fh = priv; in radio_g_tuner() local
3190 struct bttv *btv = fh->btv; in radio_g_tuner()
3212 struct bttv_fh *fh = priv; in radio_s_tuner() local
3213 struct bttv *btv = fh->btv; in radio_s_tuner()
3226 struct bttv_fh *fh = priv; in radio_s_hw_freq_seek() local
3227 struct bttv *btv = fh->btv; in radio_s_hw_freq_seek()
3238 struct bttv_fh *fh = priv; in radio_enum_freq_bands() local
3239 struct bttv *btv = fh->btv; in radio_enum_freq_bands()
3250 struct bttv_fh *fh = file->private_data; in radio_read() local
3251 struct bttv *btv = fh->btv; in radio_read()
3268 struct bttv_fh *fh = file->private_data; in radio_poll() local
3269 struct bttv *btv = fh->btv; in radio_poll()
3274 if (v4l2_event_pending(&fh->fh)) in radio_poll()
3277 poll_wait(file, &fh->fh.wait, wait); in radio_poll()