Lines Matching refs:fh

683 int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)  in check_alloc_btres_lock()  argument
687 if (fh->resources & bit) in check_alloc_btres_lock()
704 __s32 top = btv->crop[!!fh->do_crop].rect.top; in check_alloc_btres_lock()
713 __s32 end = fh->vbi_fmt.end; in check_alloc_btres_lock()
723 fh->resources |= bit; in check_alloc_btres_lock()
732 int check_btres(struct bttv_fh *fh, int bit) in check_btres() argument
734 return (fh->resources & bit); in check_btres()
773 void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits) in free_btres_lock() argument
775 if ((fh->resources & bits) != bits) { in free_btres_lock()
779 fh->resources &= ~bits; in free_btres_lock()
806 unsigned char fl, fh, fi; in set_pll_freq() local
816 fh=fout/fin; in set_pll_freq()
822 btwrite(fh, BT848_PLL_F_HI); in set_pll_freq()
1529 bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh, in bttv_switch_overlay() argument
1547 bttv_dma_free(&fh->cap,btv, old); in bttv_switch_overlay()
1551 free_btres_lock(btv,fh,RESOURCE_OVERLAY); in bttv_switch_overlay()
1565 struct bttv_fh *fh = q->priv_data; in bttv_prepare_buffer() local
1595 c = btv->crop[!!fh->do_crop]; in bttv_prepare_buffer()
1662 struct bttv_fh *fh = q->priv_data; in buffer_setup() local
1664 *size = fh->fmt->depth*fh->width*fh->height >> 3; in buffer_setup()
1677 struct bttv_fh *fh = q->priv_data; in buffer_prepare() local
1679 return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt, in buffer_prepare()
1680 fh->width, fh->height, field); in buffer_prepare()
1687 struct bttv_fh *fh = q->priv_data; in buffer_queue() local
1688 struct bttv *btv = fh->btv; in buffer_queue()
1701 struct bttv_fh *fh = q->priv_data; in buffer_release() local
1703 bttv_dma_free(q,fh->btv,buf); in buffer_release()
1726 struct bttv_fh *fh = priv; in bttv_s_std() local
1727 struct bttv *btv = fh->btv; in bttv_s_std()
1749 struct bttv_fh *fh = priv; in bttv_g_std() local
1750 struct bttv *btv = fh->btv; in bttv_g_std()
1758 struct bttv_fh *fh = f; in bttv_querystd() local
1759 struct bttv *btv = fh->btv; in bttv_querystd()
1771 struct bttv_fh *fh = priv; in bttv_enum_input() local
1772 struct bttv *btv = fh->btv; in bttv_enum_input()
1810 struct bttv_fh *fh = priv; in bttv_g_input() local
1811 struct bttv *btv = fh->btv; in bttv_g_input()
1820 struct bttv_fh *fh = priv; in bttv_s_input() local
1821 struct bttv *btv = fh->btv; in bttv_s_input()
1833 struct bttv_fh *fh = priv; in bttv_s_tuner() local
1834 struct bttv *btv = fh->btv; in bttv_s_tuner()
1852 struct bttv_fh *fh = priv; in bttv_g_frequency() local
1853 struct bttv *btv = fh->btv; in bttv_g_frequency()
1889 struct bttv_fh *fh = priv; in bttv_s_frequency() local
1890 struct bttv *btv = fh->btv; in bttv_s_frequency()
1902 struct bttv_fh *fh = f; in bttv_log_status() local
1903 struct bttv *btv = fh->btv; in bttv_log_status()
1914 struct bttv_fh *fh = f; in bttv_g_register() local
1915 struct bttv *btv = fh->btv; in bttv_g_register()
1928 struct bttv_fh *fh = f; in bttv_s_register() local
1929 struct bttv *btv = fh->btv; in bttv_s_register()
1989 limit_scaled_size_lock (struct bttv_fh * fh, in limit_scaled_size_lock() argument
1998 struct bttv *btv = fh->btv; in limit_scaled_size_lock()
2016 c = &btv->crop[!!fh->do_crop]; in limit_scaled_size_lock()
2018 if (fh->do_crop in limit_scaled_size_lock()
2101 verify_window_lock(struct bttv_fh *fh, struct v4l2_window *win, in verify_window_lock() argument
2131 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; in verify_window_lock()
2138 if (NULL == fh->ovfmt) in verify_window_lock()
2142 switch (fh->ovfmt->depth) { in verify_window_lock()
2159 rc = limit_scaled_size_lock(fh, &win->w.width, &win->w.height, in verify_window_lock()
2168 static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, in setup_window_lock() argument
2174 if (NULL == fh->ovfmt) in setup_window_lock()
2176 if (!(fh->ovfmt->flags & FORMAT_FLAGS_PACKED)) in setup_window_lock()
2178 retval = verify_window_lock(fh, win, in setup_window_lock()
2205 switch (fh->ovfmt->depth) { in setup_window_lock()
2220 kfree(fh->ov.clips); in setup_window_lock()
2221 fh->ov.clips = clips; in setup_window_lock()
2222 fh->ov.nclips = n; in setup_window_lock()
2224 fh->ov.w = win->w; in setup_window_lock()
2225 fh->ov.field = win->field; in setup_window_lock()
2226 fh->ov.setup_ok = 1; in setup_window_lock()
2234 if (check_btres(fh, RESOURCE_OVERLAY)) { in setup_window_lock()
2238 new->crop = btv->crop[!!fh->do_crop].rect; in setup_window_lock()
2239 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in setup_window_lock()
2240 retval = bttv_switch_overlay(btv,fh,new); in setup_window_lock()
2247 static struct videobuf_queue* bttv_queue(struct bttv_fh *fh) in bttv_queue() argument
2251 switch (fh->type) { in bttv_queue()
2253 q = &fh->cap; in bttv_queue()
2256 q = &fh->vbi; in bttv_queue()
2264 static int bttv_resource(struct bttv_fh *fh) in bttv_resource() argument
2268 switch (fh->type) { in bttv_resource()
2281 static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type) in bttv_switch_type() argument
2283 struct videobuf_queue *q = bttv_queue(fh); in bttv_switch_type()
2284 int res = bttv_resource(fh); in bttv_switch_type()
2286 if (check_btres(fh,res)) in bttv_switch_type()
2290 fh->type = type; in bttv_switch_type()
2315 struct bttv_fh *fh = priv; in bttv_g_fmt_vid_cap() local
2317 pix_format_set_size(&f->fmt.pix, fh->fmt, in bttv_g_fmt_vid_cap()
2318 fh->width, fh->height); in bttv_g_fmt_vid_cap()
2319 f->fmt.pix.field = fh->cap.field; in bttv_g_fmt_vid_cap()
2320 f->fmt.pix.pixelformat = fh->fmt->fourcc; in bttv_g_fmt_vid_cap()
2329 struct bttv_fh *fh = priv; in bttv_g_fmt_vid_overlay() local
2331 f->fmt.win.w = fh->ov.w; in bttv_g_fmt_vid_overlay()
2332 f->fmt.win.field = fh->ov.field; in bttv_g_fmt_vid_overlay()
2354 struct bttv_fh *fh = priv; in bttv_try_fmt_vid_cap() local
2355 struct bttv *btv = fh->btv; in bttv_try_fmt_vid_cap()
2382 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2393 rc = limit_scaled_size_lock(fh, &width, &height, field, in bttv_try_fmt_vid_cap()
2411 struct bttv_fh *fh = priv; in bttv_try_fmt_vid_overlay() local
2413 verify_window_lock(fh, &f->fmt.win, in bttv_try_fmt_vid_overlay()
2424 struct bttv_fh *fh = priv; in bttv_s_fmt_vid_cap() local
2425 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_cap()
2430 retval = bttv_switch_type(fh, f->type); in bttv_s_fmt_vid_cap()
2444 retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field, in bttv_s_fmt_vid_cap()
2454 fh->fmt = fmt; in bttv_s_fmt_vid_cap()
2455 fh->cap.field = f->fmt.pix.field; in bttv_s_fmt_vid_cap()
2456 fh->cap.last = V4L2_FIELD_NONE; in bttv_s_fmt_vid_cap()
2457 fh->width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2458 fh->height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2469 struct bttv_fh *fh = priv; in bttv_s_fmt_vid_overlay() local
2470 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_overlay()
2477 return setup_window_lock(fh, btv, &f->fmt.win, 1); in bttv_s_fmt_vid_overlay()
2484 struct bttv_fh *fh = priv; in bttv_querycap() local
2485 struct bttv *btv = fh->btv; in bttv_querycap()
2592 struct bttv_fh *fh = f; in bttv_g_fbuf() local
2593 struct bttv *btv = fh->btv; in bttv_g_fbuf()
2598 if (fh->ovfmt) in bttv_g_fbuf()
2599 fb->fmt.pixelformat = fh->ovfmt->fourcc; in bttv_g_fbuf()
2605 struct bttv_fh *fh = f; in bttv_overlay() local
2606 struct bttv *btv = fh->btv; in bttv_overlay()
2615 if (unlikely(!fh->ov.setup_ok)) { in bttv_overlay()
2623 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) in bttv_overlay()
2627 fh->ov.tvnorm = btv->tvnorm; in bttv_overlay()
2629 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_overlay()
2630 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_overlay()
2636 retval = bttv_switch_overlay(btv, fh, new); in bttv_overlay()
2643 struct bttv_fh *fh = f; in bttv_s_fbuf() local
2644 struct bttv *btv = fh->btv; in bttv_s_fbuf()
2664 retval = limit_scaled_size_lock(fh, &width, &height, in bttv_s_fbuf()
2684 fh->ovfmt = fmt; in bttv_s_fbuf()
2687 fh->ov.w.left = 0; in bttv_s_fbuf()
2688 fh->ov.w.top = 0; in bttv_s_fbuf()
2689 fh->ov.w.width = fb->fmt.width; in bttv_s_fbuf()
2690 fh->ov.w.height = fb->fmt.height; in bttv_s_fbuf()
2693 kfree(fh->ov.clips); in bttv_s_fbuf()
2694 fh->ov.clips = NULL; in bttv_s_fbuf()
2695 fh->ov.nclips = 0; in bttv_s_fbuf()
2697 if (check_btres(fh, RESOURCE_OVERLAY)) { in bttv_s_fbuf()
2701 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_s_fbuf()
2702 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_s_fbuf()
2703 retval = bttv_switch_overlay(btv, fh, new); in bttv_s_fbuf()
2712 struct bttv_fh *fh = priv; in bttv_reqbufs() local
2713 return videobuf_reqbufs(bttv_queue(fh), p); in bttv_reqbufs()
2719 struct bttv_fh *fh = priv; in bttv_querybuf() local
2720 return videobuf_querybuf(bttv_queue(fh), b); in bttv_querybuf()
2725 struct bttv_fh *fh = priv; in bttv_qbuf() local
2726 struct bttv *btv = fh->btv; in bttv_qbuf()
2727 int res = bttv_resource(fh); in bttv_qbuf()
2729 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_qbuf()
2732 return videobuf_qbuf(bttv_queue(fh), b); in bttv_qbuf()
2737 struct bttv_fh *fh = priv; in bttv_dqbuf() local
2738 return videobuf_dqbuf(bttv_queue(fh), b, in bttv_dqbuf()
2745 struct bttv_fh *fh = priv; in bttv_streamon() local
2746 struct bttv *btv = fh->btv; in bttv_streamon()
2747 int res = bttv_resource(fh); in bttv_streamon()
2749 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_streamon()
2751 return videobuf_streamon(bttv_queue(fh)); in bttv_streamon()
2758 struct bttv_fh *fh = priv; in bttv_streamoff() local
2759 struct bttv *btv = fh->btv; in bttv_streamoff()
2761 int res = bttv_resource(fh); in bttv_streamoff()
2764 retval = videobuf_streamoff(bttv_queue(fh)); in bttv_streamoff()
2767 free_btres_lock(btv, fh, res); in bttv_streamoff()
2774 struct bttv_fh *fh = f; in bttv_g_parm() local
2775 struct bttv *btv = fh->btv; in bttv_g_parm()
2789 struct bttv_fh *fh = priv; in bttv_g_tuner() local
2790 struct bttv *btv = fh->btv; in bttv_g_tuner()
2812 struct bttv_fh *fh = priv; in bttv_cropcap() local
2813 struct bttv *btv = fh->btv; in bttv_cropcap()
2826 struct bttv_fh *fh = f; in bttv_g_crop() local
2827 struct bttv *btv = fh->btv; in bttv_g_crop()
2837 crop->c = btv->crop[!!fh->do_crop].rect; in bttv_g_crop()
2844 struct bttv_fh *fh = f; in bttv_s_crop() local
2845 struct bttv *btv = fh->btv; in bttv_s_crop()
2863 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { in bttv_s_crop()
2897 fh->do_crop = 1; in bttv_s_crop()
2899 if (fh->width < c.min_scaled_width) { in bttv_s_crop()
2900 fh->width = c.min_scaled_width; in bttv_s_crop()
2902 } else if (fh->width > c.max_scaled_width) { in bttv_s_crop()
2903 fh->width = c.max_scaled_width; in bttv_s_crop()
2907 if (fh->height < c.min_scaled_height) { in bttv_s_crop()
2908 fh->height = c.min_scaled_height; in bttv_s_crop()
2910 } else if (fh->height > c.max_scaled_height) { in bttv_s_crop()
2911 fh->height = c.max_scaled_height; in bttv_s_crop()
2921 struct bttv_fh *fh = file->private_data; in bttv_read() local
2924 if (fh->btv->errors) in bttv_read()
2925 bttv_reinit_bt848(fh->btv); in bttv_read()
2927 fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]); in bttv_read()
2929 switch (fh->type) { in bttv_read()
2931 if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) { in bttv_read()
2936 retval = videobuf_read_one(&fh->cap, data, count, ppos, in bttv_read()
2938 free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ); in bttv_read()
2941 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_read()
2943 retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1, in bttv_read()
2954 struct bttv_fh *fh = file->private_data; in bttv_poll() local
2960 if (v4l2_event_pending(&fh->fh)) in bttv_poll()
2963 poll_wait(file, &fh->fh.wait, wait); in bttv_poll()
2968 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { in bttv_poll()
2969 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_poll()
2971 return rc | videobuf_poll_stream(file, &fh->vbi, wait); in bttv_poll()
2974 if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { in bttv_poll()
2976 if (list_empty(&fh->cap.stream)) in bttv_poll()
2978 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); in bttv_poll()
2981 if (NULL == fh->cap.read_buf) { in bttv_poll()
2983 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) in bttv_poll()
2985 fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize); in bttv_poll()
2986 if (NULL == fh->cap.read_buf) in bttv_poll()
2988 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; in bttv_poll()
2989 field = videobuf_next_field(&fh->cap); in bttv_poll()
2990 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { in bttv_poll()
2991 kfree (fh->cap.read_buf); in bttv_poll()
2992 fh->cap.read_buf = NULL; in bttv_poll()
2995 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); in bttv_poll()
2996 fh->cap.read_off = 0; in bttv_poll()
2998 buf = (struct bttv_buffer*)fh->cap.read_buf; in bttv_poll()
3012 struct bttv_fh *fh; in bttv_open() local
3030 fh = kmalloc(sizeof(*fh), GFP_KERNEL); in bttv_open()
3031 if (unlikely(!fh)) in bttv_open()
3034 file->private_data = fh; in bttv_open()
3036 *fh = btv->init; in bttv_open()
3037 v4l2_fh_init(&fh->fh, vdev); in bttv_open()
3039 fh->type = type; in bttv_open()
3040 fh->ov.setup_ok = 0; in bttv_open()
3042 videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, in bttv_open()
3047 fh, &btv->lock); in bttv_open()
3048 videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, in bttv_open()
3053 fh, &btv->lock); in bttv_open()
3067 fh->do_crop = !reset_crop; /* module parameter */ in bttv_open()
3072 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); in bttv_open()
3075 v4l2_fh_add(&fh->fh); in bttv_open()
3081 struct bttv_fh *fh = file->private_data; in bttv_release() local
3082 struct bttv *btv = fh->btv; in bttv_release()
3085 if (check_btres(fh, RESOURCE_OVERLAY)) in bttv_release()
3086 bttv_switch_overlay(btv,fh,NULL); in bttv_release()
3089 if (check_btres(fh, RESOURCE_VIDEO_STREAM)) { in bttv_release()
3090 videobuf_streamoff(&fh->cap); in bttv_release()
3091 free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM); in bttv_release()
3093 if (fh->cap.read_buf) { in bttv_release()
3094 buffer_release(&fh->cap,fh->cap.read_buf); in bttv_release()
3095 kfree(fh->cap.read_buf); in bttv_release()
3097 if (check_btres(fh, RESOURCE_VIDEO_READ)) { in bttv_release()
3098 free_btres_lock(btv, fh, RESOURCE_VIDEO_READ); in bttv_release()
3102 if (check_btres(fh, RESOURCE_VBI)) { in bttv_release()
3103 videobuf_stop(&fh->vbi); in bttv_release()
3104 free_btres_lock(btv,fh,RESOURCE_VBI); in bttv_release()
3109 videobuf_mmap_free(&fh->cap); in bttv_release()
3110 videobuf_mmap_free(&fh->vbi); in bttv_release()
3119 v4l2_fh_del(&fh->fh); in bttv_release()
3120 v4l2_fh_exit(&fh->fh); in bttv_release()
3121 kfree(fh); in bttv_release()
3128 struct bttv_fh *fh = file->private_data; in bttv_mmap() local
3131 fh->btv->c.nr, v4l2_type_names[fh->type], in bttv_mmap()
3133 return videobuf_mmap_mapper(bttv_queue(fh),vma); in bttv_mmap()
3205 struct bttv_fh *fh; in radio_open() local
3212 fh = kmalloc(sizeof(*fh), GFP_KERNEL); in radio_open()
3213 if (unlikely(!fh)) in radio_open()
3215 file->private_data = fh; in radio_open()
3216 *fh = btv->init; in radio_open()
3217 v4l2_fh_init(&fh->fh, vdev); in radio_open()
3222 v4l2_fh_add(&fh->fh); in radio_open()
3229 struct bttv_fh *fh = file->private_data; in radio_release() local
3230 struct bttv *btv = fh->btv; in radio_release()
3234 v4l2_fh_del(&fh->fh); in radio_release()
3235 v4l2_fh_exit(&fh->fh); in radio_release()
3236 kfree(fh); in radio_release()
3249 struct bttv_fh *fh = priv; in radio_g_tuner() local
3250 struct bttv *btv = fh->btv; in radio_g_tuner()
3272 struct bttv_fh *fh = priv; in radio_s_tuner() local
3273 struct bttv *btv = fh->btv; in radio_s_tuner()
3286 struct bttv_fh *fh = priv; in radio_s_hw_freq_seek() local
3287 struct bttv *btv = fh->btv; in radio_s_hw_freq_seek()
3298 struct bttv_fh *fh = priv; in radio_enum_freq_bands() local
3299 struct bttv *btv = fh->btv; in radio_enum_freq_bands()
3310 struct bttv_fh *fh = file->private_data; in radio_read() local
3311 struct bttv *btv = fh->btv; in radio_read()
3328 struct bttv_fh *fh = file->private_data; in radio_poll() local
3329 struct bttv *btv = fh->btv; in radio_poll()
3334 if (v4l2_event_pending(&fh->fh)) in radio_poll()
3337 poll_wait(file, &fh->fh.wait, wait); in radio_poll()