diff options
| author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-02-03 08:46:55 -0500 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-03-02 15:08:48 -0500 |
| commit | cee05cb3598813f05a3419c56487e337ee84210f (patch) | |
| tree | 51d42021890315b56bc136b94d16950aef9ac8ac /drivers/media/usb | |
| parent | 5cf6f7f327c95f09be859889be39e78950516556 (diff) | |
[media] pvrusb2: use struct v4l2_fh
By using struct v4l2_fh both the prio handling and the linked list
implementation in pvrusb2 can be removed since both are now done in
the v4l2 core if you use struct v4l2_fh.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb')
| -rw-r--r-- | drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 81 |
1 files changed, 13 insertions, 68 deletions
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index 91c1700eb070..802b43b23d0c 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
| 33 | #include <media/v4l2-dev.h> | 33 | #include <media/v4l2-dev.h> |
| 34 | #include <media/v4l2-device.h> | 34 | #include <media/v4l2-device.h> |
| 35 | #include <media/v4l2-fh.h> | ||
| 35 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
| 36 | #include <media/v4l2-ioctl.h> | 37 | #include <media/v4l2-ioctl.h> |
| 37 | 38 | ||
| @@ -50,14 +51,11 @@ struct pvr2_v4l2_dev { | |||
| 50 | }; | 51 | }; |
| 51 | 52 | ||
| 52 | struct pvr2_v4l2_fh { | 53 | struct pvr2_v4l2_fh { |
| 54 | struct v4l2_fh fh; | ||
| 53 | struct pvr2_channel channel; | 55 | struct pvr2_channel channel; |
| 54 | struct pvr2_v4l2_dev *pdi; | 56 | struct pvr2_v4l2_dev *pdi; |
| 55 | enum v4l2_priority prio; | ||
| 56 | struct pvr2_ioread *rhp; | 57 | struct pvr2_ioread *rhp; |
| 57 | struct file *file; | 58 | struct file *file; |
| 58 | struct pvr2_v4l2 *vhead; | ||
| 59 | struct pvr2_v4l2_fh *vnext; | ||
| 60 | struct pvr2_v4l2_fh *vprev; | ||
| 61 | wait_queue_head_t wait_data; | 59 | wait_queue_head_t wait_data; |
| 62 | int fw_mode_flag; | 60 | int fw_mode_flag; |
| 63 | /* Map contiguous ordinal value to input id */ | 61 | /* Map contiguous ordinal value to input id */ |
| @@ -67,10 +65,6 @@ struct pvr2_v4l2_fh { | |||
| 67 | 65 | ||
| 68 | struct pvr2_v4l2 { | 66 | struct pvr2_v4l2 { |
| 69 | struct pvr2_channel channel; | 67 | struct pvr2_channel channel; |
| 70 | struct pvr2_v4l2_fh *vfirst; | ||
| 71 | struct pvr2_v4l2_fh *vlast; | ||
| 72 | |||
| 73 | struct v4l2_prio_state prio; | ||
| 74 | 68 | ||
| 75 | /* streams - Note that these must be separately, individually, | 69 | /* streams - Note that these must be separately, individually, |
| 76 | * allocated pointers. This is because the v4l core is going to | 70 | * allocated pointers. This is because the v4l core is going to |
| @@ -169,23 +163,6 @@ static int pvr2_querycap(struct file *file, void *priv, struct v4l2_capability * | |||
| 169 | return 0; | 163 | return 0; |
| 170 | } | 164 | } |
| 171 | 165 | ||
| 172 | static int pvr2_g_priority(struct file *file, void *priv, enum v4l2_priority *p) | ||
| 173 | { | ||
| 174 | struct pvr2_v4l2_fh *fh = file->private_data; | ||
| 175 | struct pvr2_v4l2 *vp = fh->vhead; | ||
| 176 | |||
| 177 | *p = v4l2_prio_max(&vp->prio); | ||
| 178 | return 0; | ||
| 179 | } | ||
| 180 | |||
| 181 | static int pvr2_s_priority(struct file *file, void *priv, enum v4l2_priority prio) | ||
| 182 | { | ||
| 183 | struct pvr2_v4l2_fh *fh = file->private_data; | ||
| 184 | struct pvr2_v4l2 *vp = fh->vhead; | ||
| 185 | |||
| 186 | return v4l2_prio_change(&vp->prio, &fh->prio, prio); | ||
| 187 | } | ||
| 188 | |||
| 189 | static int pvr2_g_std(struct file *file, void *priv, v4l2_std_id *std) | 166 | static int pvr2_g_std(struct file *file, void *priv, v4l2_std_id *std) |
| 190 | { | 167 | { |
| 191 | struct pvr2_v4l2_fh *fh = file->private_data; | 168 | struct pvr2_v4l2_fh *fh = file->private_data; |
| @@ -805,8 +782,6 @@ static int pvr2_log_status(struct file *file, void *priv) | |||
| 805 | 782 | ||
| 806 | static const struct v4l2_ioctl_ops pvr2_ioctl_ops = { | 783 | static const struct v4l2_ioctl_ops pvr2_ioctl_ops = { |
| 807 | .vidioc_querycap = pvr2_querycap, | 784 | .vidioc_querycap = pvr2_querycap, |
| 808 | .vidioc_g_priority = pvr2_g_priority, | ||
| 809 | .vidioc_s_priority = pvr2_s_priority, | ||
| 810 | .vidioc_s_audio = pvr2_s_audio, | 785 | .vidioc_s_audio = pvr2_s_audio, |
| 811 | .vidioc_g_audio = pvr2_g_audio, | 786 | .vidioc_g_audio = pvr2_g_audio, |
| 812 | .vidioc_enumaudio = pvr2_enumaudio, | 787 | .vidioc_enumaudio = pvr2_enumaudio, |
| @@ -911,7 +886,9 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp) | |||
| 911 | if (!vp->channel.mc_head->disconnect_flag) return; | 886 | if (!vp->channel.mc_head->disconnect_flag) return; |
| 912 | pvr2_v4l2_dev_disassociate_parent(vp->dev_video); | 887 | pvr2_v4l2_dev_disassociate_parent(vp->dev_video); |
| 913 | pvr2_v4l2_dev_disassociate_parent(vp->dev_radio); | 888 | pvr2_v4l2_dev_disassociate_parent(vp->dev_radio); |
| 914 | if (vp->vfirst) return; | 889 | if (!list_empty(&vp->dev_video->devbase.fh_list) || |
| 890 | !list_empty(&vp->dev_radio->devbase.fh_list)) | ||
| 891 | return; | ||
| 915 | pvr2_v4l2_destroy_no_lock(vp); | 892 | pvr2_v4l2_destroy_no_lock(vp); |
| 916 | } | 893 | } |
| 917 | 894 | ||
| @@ -921,7 +898,6 @@ static long pvr2_v4l2_ioctl(struct file *file, | |||
| 921 | { | 898 | { |
| 922 | 899 | ||
| 923 | struct pvr2_v4l2_fh *fh = file->private_data; | 900 | struct pvr2_v4l2_fh *fh = file->private_data; |
| 924 | struct pvr2_v4l2 *vp = fh->vhead; | ||
| 925 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; | 901 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; |
| 926 | long ret = -EINVAL; | 902 | long ret = -EINVAL; |
| 927 | 903 | ||
| @@ -934,18 +910,6 @@ static long pvr2_v4l2_ioctl(struct file *file, | |||
| 934 | return -EFAULT; | 910 | return -EFAULT; |
| 935 | } | 911 | } |
| 936 | 912 | ||
| 937 | /* check priority */ | ||
| 938 | switch (cmd) { | ||
| 939 | case VIDIOC_S_CTRL: | ||
| 940 | case VIDIOC_S_STD: | ||
| 941 | case VIDIOC_S_INPUT: | ||
| 942 | case VIDIOC_S_TUNER: | ||
| 943 | case VIDIOC_S_FREQUENCY: | ||
| 944 | ret = v4l2_prio_check(&vp->prio, fh->prio); | ||
| 945 | if (ret) | ||
| 946 | return ret; | ||
| 947 | } | ||
| 948 | |||
| 949 | ret = video_ioctl2(file, cmd, arg); | 913 | ret = video_ioctl2(file, cmd, arg); |
| 950 | 914 | ||
| 951 | pvr2_hdw_commit_ctl(hdw); | 915 | pvr2_hdw_commit_ctl(hdw); |
| @@ -970,7 +934,7 @@ static long pvr2_v4l2_ioctl(struct file *file, | |||
| 970 | static int pvr2_v4l2_release(struct file *file) | 934 | static int pvr2_v4l2_release(struct file *file) |
| 971 | { | 935 | { |
| 972 | struct pvr2_v4l2_fh *fhp = file->private_data; | 936 | struct pvr2_v4l2_fh *fhp = file->private_data; |
| 973 | struct pvr2_v4l2 *vp = fhp->vhead; | 937 | struct pvr2_v4l2 *vp = fhp->pdi->v4lp; |
| 974 | struct pvr2_hdw *hdw = fhp->channel.mc_head->hdw; | 938 | struct pvr2_hdw *hdw = fhp->channel.mc_head->hdw; |
| 975 | 939 | ||
| 976 | pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_release"); | 940 | pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_release"); |
| @@ -984,22 +948,10 @@ static int pvr2_v4l2_release(struct file *file) | |||
| 984 | fhp->rhp = NULL; | 948 | fhp->rhp = NULL; |
| 985 | } | 949 | } |
| 986 | 950 | ||
| 987 | v4l2_prio_close(&vp->prio, fhp->prio); | 951 | v4l2_fh_del(&fhp->fh); |
| 952 | v4l2_fh_exit(&fhp->fh); | ||
| 988 | file->private_data = NULL; | 953 | file->private_data = NULL; |
| 989 | 954 | ||
| 990 | if (fhp->vnext) { | ||
| 991 | fhp->vnext->vprev = fhp->vprev; | ||
| 992 | } else { | ||
| 993 | vp->vlast = fhp->vprev; | ||
| 994 | } | ||
| 995 | if (fhp->vprev) { | ||
| 996 | fhp->vprev->vnext = fhp->vnext; | ||
| 997 | } else { | ||
| 998 | vp->vfirst = fhp->vnext; | ||
| 999 | } | ||
| 1000 | fhp->vnext = NULL; | ||
| 1001 | fhp->vprev = NULL; | ||
| 1002 | fhp->vhead = NULL; | ||
| 1003 | pvr2_channel_done(&fhp->channel); | 955 | pvr2_channel_done(&fhp->channel); |
| 1004 | pvr2_trace(PVR2_TRACE_STRUCT, | 956 | pvr2_trace(PVR2_TRACE_STRUCT, |
| 1005 | "Destroying pvr_v4l2_fh id=%p",fhp); | 957 | "Destroying pvr_v4l2_fh id=%p",fhp); |
| @@ -1008,7 +960,9 @@ static int pvr2_v4l2_release(struct file *file) | |||
| 1008 | fhp->input_map = NULL; | 960 | fhp->input_map = NULL; |
| 1009 | } | 961 | } |
| 1010 | kfree(fhp); | 962 | kfree(fhp); |
| 1011 | if (vp->channel.mc_head->disconnect_flag && !vp->vfirst) { | 963 | if (vp->channel.mc_head->disconnect_flag && |
| 964 | list_empty(&vp->dev_video->devbase.fh_list) && | ||
| 965 | list_empty(&vp->dev_radio->devbase.fh_list)) { | ||
| 1012 | pvr2_v4l2_destroy_no_lock(vp); | 966 | pvr2_v4l2_destroy_no_lock(vp); |
| 1013 | } | 967 | } |
| 1014 | return 0; | 968 | return 0; |
| @@ -1043,6 +997,7 @@ static int pvr2_v4l2_open(struct file *file) | |||
| 1043 | return -ENOMEM; | 997 | return -ENOMEM; |
| 1044 | } | 998 | } |
| 1045 | 999 | ||
| 1000 | v4l2_fh_init(&fhp->fh, &dip->devbase); | ||
| 1046 | init_waitqueue_head(&fhp->wait_data); | 1001 | init_waitqueue_head(&fhp->wait_data); |
| 1047 | fhp->pdi = dip; | 1002 | fhp->pdi = dip; |
| 1048 | 1003 | ||
| @@ -1093,21 +1048,11 @@ static int pvr2_v4l2_open(struct file *file) | |||
| 1093 | fhp->input_map[input_cnt++] = idx; | 1048 | fhp->input_map[input_cnt++] = idx; |
| 1094 | } | 1049 | } |
| 1095 | 1050 | ||
| 1096 | fhp->vnext = NULL; | ||
| 1097 | fhp->vprev = vp->vlast; | ||
| 1098 | if (vp->vlast) { | ||
| 1099 | vp->vlast->vnext = fhp; | ||
| 1100 | } else { | ||
| 1101 | vp->vfirst = fhp; | ||
| 1102 | } | ||
| 1103 | vp->vlast = fhp; | ||
| 1104 | fhp->vhead = vp; | ||
| 1105 | |||
| 1106 | fhp->file = file; | 1051 | fhp->file = file; |
| 1107 | file->private_data = fhp; | 1052 | file->private_data = fhp; |
| 1108 | v4l2_prio_open(&vp->prio, &fhp->prio); | ||
| 1109 | 1053 | ||
| 1110 | fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw); | 1054 | fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw); |
| 1055 | v4l2_fh_add(&fhp->fh); | ||
| 1111 | 1056 | ||
| 1112 | return 0; | 1057 | return 0; |
| 1113 | } | 1058 | } |
