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
2086 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; in verify_window_lock()
2093 if (NULL == fh->ovfmt) in verify_window_lock()
2097 switch (fh->ovfmt->depth) { in verify_window_lock()
2114 rc = limit_scaled_size_lock(fh, &win->w.width, &win->w.height, in verify_window_lock()
2123 static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, in setup_window_lock() argument
2129 if (NULL == fh->ovfmt) in setup_window_lock()
2131 if (!(fh->ovfmt->flags & FORMAT_FLAGS_PACKED)) in setup_window_lock()
2133 retval = verify_window_lock(fh, win, in setup_window_lock()
2160 switch (fh->ovfmt->depth) { in setup_window_lock()
2175 kfree(fh->ov.clips); in setup_window_lock()
2176 fh->ov.clips = clips; in setup_window_lock()
2177 fh->ov.nclips = n; in setup_window_lock()
2179 fh->ov.w = win->w; in setup_window_lock()
2180 fh->ov.field = win->field; in setup_window_lock()
2181 fh->ov.setup_ok = 1; in setup_window_lock()
2189 if (check_btres(fh, RESOURCE_OVERLAY)) { in setup_window_lock()
2193 new->crop = btv->crop[!!fh->do_crop].rect; in setup_window_lock()
2194 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in setup_window_lock()
2195 retval = bttv_switch_overlay(btv,fh,new); in setup_window_lock()
2202 static struct videobuf_queue* bttv_queue(struct bttv_fh *fh) in bttv_queue() argument
2206 switch (fh->type) { in bttv_queue()
2208 q = &fh->cap; in bttv_queue()
2211 q = &fh->vbi; in bttv_queue()
2219 static int bttv_resource(struct bttv_fh *fh) in bttv_resource() argument
2223 switch (fh->type) { in bttv_resource()
2236 static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type) in bttv_switch_type() argument
2238 struct videobuf_queue *q = bttv_queue(fh); in bttv_switch_type()
2239 int res = bttv_resource(fh); in bttv_switch_type()
2241 if (check_btres(fh,res)) in bttv_switch_type()
2245 fh->type = type; in bttv_switch_type()
2270 struct bttv_fh *fh = priv; in bttv_g_fmt_vid_cap() local
2272 pix_format_set_size(&f->fmt.pix, fh->fmt, in bttv_g_fmt_vid_cap()
2273 fh->width, fh->height); in bttv_g_fmt_vid_cap()
2274 f->fmt.pix.field = fh->cap.field; in bttv_g_fmt_vid_cap()
2275 f->fmt.pix.pixelformat = fh->fmt->fourcc; in bttv_g_fmt_vid_cap()
2284 struct bttv_fh *fh = priv; in bttv_g_fmt_vid_overlay() local
2286 f->fmt.win.w = fh->ov.w; in bttv_g_fmt_vid_overlay()
2287 f->fmt.win.field = fh->ov.field; in bttv_g_fmt_vid_overlay()
2309 struct bttv_fh *fh = priv; in bttv_try_fmt_vid_cap() local
2310 struct bttv *btv = fh->btv; in bttv_try_fmt_vid_cap()
2337 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2348 rc = limit_scaled_size_lock(fh, &width, &height, field, in bttv_try_fmt_vid_cap()
2366 struct bttv_fh *fh = priv; in bttv_try_fmt_vid_overlay() local
2368 verify_window_lock(fh, &f->fmt.win, in bttv_try_fmt_vid_overlay()
2379 struct bttv_fh *fh = priv; in bttv_s_fmt_vid_cap() local
2380 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_cap()
2385 retval = bttv_switch_type(fh, f->type); in bttv_s_fmt_vid_cap()
2399 retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field, in bttv_s_fmt_vid_cap()
2409 fh->fmt = fmt; in bttv_s_fmt_vid_cap()
2410 fh->cap.field = f->fmt.pix.field; in bttv_s_fmt_vid_cap()
2411 fh->cap.last = V4L2_FIELD_NONE; in bttv_s_fmt_vid_cap()
2412 fh->width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2413 fh->height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2424 struct bttv_fh *fh = priv; in bttv_s_fmt_vid_overlay() local
2425 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_overlay()
2432 return setup_window_lock(fh, btv, &f->fmt.win, 1); in bttv_s_fmt_vid_overlay()
2438 struct bttv_fh *fh = priv; in bttv_querycap() local
2439 struct bttv *btv = fh->btv; in bttv_querycap()
2524 struct bttv_fh *fh = f; in bttv_g_fbuf() local
2525 struct bttv *btv = fh->btv; in bttv_g_fbuf()
2530 if (fh->ovfmt) in bttv_g_fbuf()
2531 fb->fmt.pixelformat = fh->ovfmt->fourcc; in bttv_g_fbuf()
2537 struct bttv_fh *fh = f; in bttv_overlay() local
2538 struct bttv *btv = fh->btv; in bttv_overlay()
2547 if (unlikely(!fh->ov.setup_ok)) { in bttv_overlay()
2555 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) in bttv_overlay()
2559 fh->ov.tvnorm = btv->tvnorm; in bttv_overlay()
2561 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_overlay()
2562 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_overlay()
2568 retval = bttv_switch_overlay(btv, fh, new); in bttv_overlay()
2575 struct bttv_fh *fh = f; in bttv_s_fbuf() local
2576 struct bttv *btv = fh->btv; in bttv_s_fbuf()
2596 retval = limit_scaled_size_lock(fh, &width, &height, in bttv_s_fbuf()
2616 fh->ovfmt = fmt; in bttv_s_fbuf()
2619 fh->ov.w.left = 0; in bttv_s_fbuf()
2620 fh->ov.w.top = 0; in bttv_s_fbuf()
2621 fh->ov.w.width = fb->fmt.width; in bttv_s_fbuf()
2622 fh->ov.w.height = fb->fmt.height; in bttv_s_fbuf()
2626 kfree(fh->ov.clips); in bttv_s_fbuf()
2627 fh->ov.clips = NULL; in bttv_s_fbuf()
2628 fh->ov.nclips = 0; in bttv_s_fbuf()
2630 if (check_btres(fh, RESOURCE_OVERLAY)) { in bttv_s_fbuf()
2634 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_s_fbuf()
2635 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_s_fbuf()
2636 retval = bttv_switch_overlay(btv, fh, new); in bttv_s_fbuf()
2645 struct bttv_fh *fh = priv; in bttv_reqbufs() local
2646 return videobuf_reqbufs(bttv_queue(fh), p); in bttv_reqbufs()
2652 struct bttv_fh *fh = priv; in bttv_querybuf() local
2653 return videobuf_querybuf(bttv_queue(fh), b); in bttv_querybuf()
2658 struct bttv_fh *fh = priv; in bttv_qbuf() local
2659 struct bttv *btv = fh->btv; in bttv_qbuf()
2660 int res = bttv_resource(fh); in bttv_qbuf()
2662 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_qbuf()
2665 return videobuf_qbuf(bttv_queue(fh), b); in bttv_qbuf()
2670 struct bttv_fh *fh = priv; in bttv_dqbuf() local
2671 return videobuf_dqbuf(bttv_queue(fh), b, in bttv_dqbuf()
2678 struct bttv_fh *fh = priv; in bttv_streamon() local
2679 struct bttv *btv = fh->btv; in bttv_streamon()
2680 int res = bttv_resource(fh); in bttv_streamon()
2682 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_streamon()
2684 return videobuf_streamon(bttv_queue(fh)); in bttv_streamon()
2691 struct bttv_fh *fh = priv; in bttv_streamoff() local
2692 struct bttv *btv = fh->btv; in bttv_streamoff()
2694 int res = bttv_resource(fh); in bttv_streamoff()
2697 retval = videobuf_streamoff(bttv_queue(fh)); in bttv_streamoff()
2700 free_btres_lock(btv, fh, res); in bttv_streamoff()
2707 struct bttv_fh *fh = f; in bttv_g_parm() local
2708 struct bttv *btv = fh->btv; in bttv_g_parm()
2722 struct bttv_fh *fh = priv; in bttv_g_tuner() local
2723 struct bttv *btv = fh->btv; in bttv_g_tuner()
2745 struct bttv_fh *fh = priv; in bttv_g_pixelaspect() local
2746 struct bttv *btv = fh->btv; in bttv_g_pixelaspect()
2758 struct bttv_fh *fh = f; in bttv_g_selection() local
2759 struct bttv *btv = fh->btv; in bttv_g_selection()
2772 sel->r = btv->crop[!!fh->do_crop].rect; in bttv_g_selection()
2789 struct bttv_fh *fh = f; in bttv_s_selection() local
2790 struct bttv *btv = fh->btv; in bttv_s_selection()
2811 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { in bttv_s_selection()
2847 fh->do_crop = 1; in bttv_s_selection()
2849 if (fh->width < c.min_scaled_width) { in bttv_s_selection()
2850 fh->width = c.min_scaled_width; in bttv_s_selection()
2852 } else if (fh->width > c.max_scaled_width) { in bttv_s_selection()
2853 fh->width = c.max_scaled_width; in bttv_s_selection()
2857 if (fh->height < c.min_scaled_height) { in bttv_s_selection()
2858 fh->height = c.min_scaled_height; in bttv_s_selection()
2860 } else if (fh->height > c.max_scaled_height) { in bttv_s_selection()
2861 fh->height = c.max_scaled_height; in bttv_s_selection()
2871 struct bttv_fh *fh = file->private_data; in bttv_read() local
2874 if (fh->btv->errors) in bttv_read()
2875 bttv_reinit_bt848(fh->btv); in bttv_read()
2877 fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]); in bttv_read()
2879 switch (fh->type) { in bttv_read()
2881 if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) { in bttv_read()
2886 retval = videobuf_read_one(&fh->cap, data, count, ppos, in bttv_read()
2888 free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ); in bttv_read()
2891 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_read()
2893 retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1, in bttv_read()
2904 struct bttv_fh *fh = file->private_data; in bttv_poll() local
2910 if (v4l2_event_pending(&fh->fh)) in bttv_poll()
2913 poll_wait(file, &fh->fh.wait, wait); in bttv_poll()
2918 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { in bttv_poll()
2919 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_poll()
2921 return rc | videobuf_poll_stream(file, &fh->vbi, wait); in bttv_poll()
2924 if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { in bttv_poll()
2926 if (list_empty(&fh->cap.stream)) in bttv_poll()
2928 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); in bttv_poll()
2931 if (NULL == fh->cap.read_buf) { in bttv_poll()
2933 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) in bttv_poll()
2935 fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize); in bttv_poll()
2936 if (NULL == fh->cap.read_buf) in bttv_poll()
2938 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; in bttv_poll()
2939 field = videobuf_next_field(&fh->cap); in bttv_poll()
2940 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { in bttv_poll()
2941 kfree (fh->cap.read_buf); in bttv_poll()
2942 fh->cap.read_buf = NULL; in bttv_poll()
2945 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); in bttv_poll()
2946 fh->cap.read_off = 0; in bttv_poll()
2948 buf = (struct bttv_buffer*)fh->cap.read_buf; in bttv_poll()
2962 struct bttv_fh *fh; in bttv_open() local
2980 fh = kmalloc(sizeof(*fh), GFP_KERNEL); in bttv_open()
2981 if (unlikely(!fh)) in bttv_open()
2984 file->private_data = fh; in bttv_open()
2986 *fh = btv->init; in bttv_open()
2987 v4l2_fh_init(&fh->fh, vdev); in bttv_open()
2989 fh->type = type; in bttv_open()
2990 fh->ov.setup_ok = 0; in bttv_open()
2992 videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, in bttv_open()
2997 fh, &btv->lock); in bttv_open()
2998 videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, in bttv_open()
3003 fh, &btv->lock); in bttv_open()
3017 fh->do_crop = !reset_crop; /* module parameter */ in bttv_open()
3022 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); in bttv_open()
3025 v4l2_fh_add(&fh->fh); in bttv_open()
3031 struct bttv_fh *fh = file->private_data; in bttv_release() local
3032 struct bttv *btv = fh->btv; in bttv_release()
3035 if (check_btres(fh, RESOURCE_OVERLAY)) in bttv_release()
3036 bttv_switch_overlay(btv,fh,NULL); in bttv_release()
3039 if (check_btres(fh, RESOURCE_VIDEO_STREAM)) { in bttv_release()
3040 videobuf_streamoff(&fh->cap); in bttv_release()
3041 free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM); in bttv_release()
3043 if (fh->cap.read_buf) { in bttv_release()
3044 buffer_release(&fh->cap,fh->cap.read_buf); in bttv_release()
3045 kfree(fh->cap.read_buf); in bttv_release()
3047 if (check_btres(fh, RESOURCE_VIDEO_READ)) { in bttv_release()
3048 free_btres_lock(btv, fh, RESOURCE_VIDEO_READ); in bttv_release()
3052 if (check_btres(fh, RESOURCE_VBI)) { in bttv_release()
3053 videobuf_stop(&fh->vbi); in bttv_release()
3054 free_btres_lock(btv,fh,RESOURCE_VBI); in bttv_release()
3059 videobuf_mmap_free(&fh->cap); in bttv_release()
3060 videobuf_mmap_free(&fh->vbi); in bttv_release()
3069 v4l2_fh_del(&fh->fh); in bttv_release()
3070 v4l2_fh_exit(&fh->fh); in bttv_release()
3071 kfree(fh); in bttv_release()
3078 struct bttv_fh *fh = file->private_data; in bttv_mmap() local
3081 fh->btv->c.nr, v4l2_type_names[fh->type], in bttv_mmap()
3083 return videobuf_mmap_mapper(bttv_queue(fh),vma); in bttv_mmap()
3155 struct bttv_fh *fh; in radio_open() local
3162 fh = kmalloc(sizeof(*fh), GFP_KERNEL); in radio_open()
3163 if (unlikely(!fh)) in radio_open()
3165 file->private_data = fh; in radio_open()
3166 *fh = btv->init; in radio_open()
3167 v4l2_fh_init(&fh->fh, vdev); in radio_open()
3172 v4l2_fh_add(&fh->fh); in radio_open()
3179 struct bttv_fh *fh = file->private_data; in radio_release() local
3180 struct bttv *btv = fh->btv; in radio_release()
3184 v4l2_fh_del(&fh->fh); in radio_release()
3185 v4l2_fh_exit(&fh->fh); in radio_release()
3186 kfree(fh); in radio_release()
3199 struct bttv_fh *fh = priv; in radio_g_tuner() local
3200 struct bttv *btv = fh->btv; in radio_g_tuner()
3222 struct bttv_fh *fh = priv; in radio_s_tuner() local
3223 struct bttv *btv = fh->btv; in radio_s_tuner()
3236 struct bttv_fh *fh = priv; in radio_s_hw_freq_seek() local
3237 struct bttv *btv = fh->btv; in radio_s_hw_freq_seek()
3248 struct bttv_fh *fh = priv; in radio_enum_freq_bands() local
3249 struct bttv *btv = fh->btv; in radio_enum_freq_bands()
3260 struct bttv_fh *fh = file->private_data; in radio_read() local
3261 struct bttv *btv = fh->btv; in radio_read()
3278 struct bttv_fh *fh = file->private_data; in radio_poll() local
3279 struct bttv *btv = fh->btv; in radio_poll()
3284 if (v4l2_event_pending(&fh->fh)) in radio_poll()
3287 poll_wait(file, &fh->fh.wait, wait); in radio_poll()