aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2011-10-11 04:18:08 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-01-16 06:59:10 -0500
commit3f3edd7c97d0a5ae355aace36000576acbc2f2cc (patch)
tree1b5f280de68f1d67a8fdc5df5e2203e9a0194dc7 /drivers
parentaa07eec5320cf1793062c03b8409e7541ca37c31 (diff)
[media] ivtv: remove exclusive radio open
For some reason the /dev/radio device was implemented as an exclusive open: you could open it only once and not a second time. Remove this limitation. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Andy Walls <awalls@md.metrocast.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c57
1 files changed, 24 insertions, 33 deletions
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 38f052257f46..69a3de9bae62 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -861,20 +861,10 @@ int ivtv_v4l2_close(struct file *filp)
861 861
862 IVTV_DEBUG_FILE("close %s\n", s->name); 862 IVTV_DEBUG_FILE("close %s\n", s->name);
863 863
864 v4l2_fh_del(fh);
865 v4l2_fh_exit(fh);
866
867 /* Easy case first: this stream was never claimed by us */
868 if (s->id != id->open_id) {
869 kfree(id);
870 return 0;
871 }
872
873 /* 'Unclaim' this stream */
874
875 /* Stop radio */
876 mutex_lock(&itv->serialize_lock); 864 mutex_lock(&itv->serialize_lock);
877 if (id->type == IVTV_ENC_STREAM_TYPE_RAD) { 865 /* Stop radio */
866 if (id->type == IVTV_ENC_STREAM_TYPE_RAD &&
867 v4l2_fh_is_singular_file(filp)) {
878 /* Closing radio device, return to TV mode */ 868 /* Closing radio device, return to TV mode */
879 ivtv_mute(itv); 869 ivtv_mute(itv);
880 /* Mark that the radio is no longer in use */ 870 /* Mark that the radio is no longer in use */
@@ -890,13 +880,26 @@ int ivtv_v4l2_close(struct file *filp)
890 if (atomic_read(&itv->capturing) > 0) { 880 if (atomic_read(&itv->capturing) > 0) {
891 /* Undo video mute */ 881 /* Undo video mute */
892 ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1, 882 ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1,
893 v4l2_ctrl_g_ctrl(itv->cxhdl.video_mute) | 883 v4l2_ctrl_g_ctrl(itv->cxhdl.video_mute) |
894 (v4l2_ctrl_g_ctrl(itv->cxhdl.video_mute_yuv) << 8)); 884 (v4l2_ctrl_g_ctrl(itv->cxhdl.video_mute_yuv) << 8));
895 } 885 }
896 /* Done! Unmute and continue. */ 886 /* Done! Unmute and continue. */
897 ivtv_unmute(itv); 887 ivtv_unmute(itv);
898 ivtv_release_stream(s); 888 }
899 } else if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) { 889
890 v4l2_fh_del(fh);
891 v4l2_fh_exit(fh);
892
893 /* Easy case first: this stream was never claimed by us */
894 if (s->id != id->open_id) {
895 kfree(id);
896 mutex_unlock(&itv->serialize_lock);
897 return 0;
898 }
899
900 /* 'Unclaim' this stream */
901
902 if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) {
900 struct ivtv_stream *s_vout = &itv->streams[IVTV_DEC_STREAM_TYPE_VOUT]; 903 struct ivtv_stream *s_vout = &itv->streams[IVTV_DEC_STREAM_TYPE_VOUT];
901 904
902 ivtv_stop_decoding(id, VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY, 0); 905 ivtv_stop_decoding(id, VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY, 0);
@@ -966,31 +969,20 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp)
966 return -ENOMEM; 969 return -ENOMEM;
967 } 970 }
968 v4l2_fh_init(&item->fh, s->vdev); 971 v4l2_fh_init(&item->fh, s->vdev);
969 if (res < 0) {
970 v4l2_fh_exit(&item->fh);
971 kfree(item);
972 return res;
973 }
974 item->itv = itv; 972 item->itv = itv;
975 item->type = s->type; 973 item->type = s->type;
976 974
977 item->open_id = itv->open_id++; 975 item->open_id = itv->open_id++;
978 filp->private_data = &item->fh; 976 filp->private_data = &item->fh;
977 v4l2_fh_add(&item->fh);
979 978
980 if (item->type == IVTV_ENC_STREAM_TYPE_RAD) { 979 if (item->type == IVTV_ENC_STREAM_TYPE_RAD &&
981 /* Try to claim this stream */ 980 v4l2_fh_is_singular_file(filp)) {
982 if (ivtv_claim_stream(item, item->type)) {
983 /* No, it's already in use */
984 v4l2_fh_exit(&item->fh);
985 kfree(item);
986 return -EBUSY;
987 }
988
989 if (!test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) { 981 if (!test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
990 if (atomic_read(&itv->capturing) > 0) { 982 if (atomic_read(&itv->capturing) > 0) {
991 /* switching to radio while capture is 983 /* switching to radio while capture is
992 in progress is not polite */ 984 in progress is not polite */
993 ivtv_release_stream(s); 985 v4l2_fh_del(&item->fh);
994 v4l2_fh_exit(&item->fh); 986 v4l2_fh_exit(&item->fh);
995 kfree(item); 987 kfree(item);
996 return -EBUSY; 988 return -EBUSY;
@@ -1022,7 +1014,6 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp)
1022 1080 * ((itv->yuv_info.v4l2_src_h + 31) & ~31); 1014 1080 * ((itv->yuv_info.v4l2_src_h + 31) & ~31);
1023 itv->yuv_info.stream_size = 0; 1015 itv->yuv_info.stream_size = 0;
1024 } 1016 }
1025 v4l2_fh_add(&item->fh);
1026 return 0; 1017 return 0;
1027} 1018}
1028 1019