aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-blackbird.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx88/cx88-blackbird.c')
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 078be6319556..d3ae5b4dfca7 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1078,7 +1078,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
1078 } 1078 }
1079 } 1079 }
1080 1080
1081 if (blackbird_initialize_codec(dev) < 0) { 1081 if (!atomic_read(&dev->core->mpeg_users) && blackbird_initialize_codec(dev) < 0) {
1082 if (drv) 1082 if (drv)
1083 drv->request_release(drv); 1083 drv->request_release(drv);
1084 unlock_kernel(); 1084 unlock_kernel();
@@ -1109,6 +1109,8 @@ static int mpeg_open(struct inode *inode, struct file *file)
1109 fh->mpegq.field); 1109 fh->mpegq.field);
1110 unlock_kernel(); 1110 unlock_kernel();
1111 1111
1112 atomic_inc(&dev->core->mpeg_users);
1113
1112 return 0; 1114 return 0;
1113} 1115}
1114 1116
@@ -1118,7 +1120,7 @@ static int mpeg_release(struct inode *inode, struct file *file)
1118 struct cx8802_dev *dev = fh->dev; 1120 struct cx8802_dev *dev = fh->dev;
1119 struct cx8802_driver *drv = NULL; 1121 struct cx8802_driver *drv = NULL;
1120 1122
1121 if (dev->mpeg_active) 1123 if (dev->mpeg_active && atomic_read(&dev->core->mpeg_users) == 1)
1122 blackbird_stop_codec(dev); 1124 blackbird_stop_codec(dev);
1123 1125
1124 cx8802_cancel_buffers(fh->dev); 1126 cx8802_cancel_buffers(fh->dev);
@@ -1138,6 +1140,8 @@ static int mpeg_release(struct inode *inode, struct file *file)
1138 if (drv) 1140 if (drv)
1139 drv->request_release(drv); 1141 drv->request_release(drv);
1140 1142
1143 atomic_dec(&dev->core->mpeg_users);
1144
1141 return 0; 1145 return 0;
1142} 1146}
1143 1147
@@ -1158,6 +1162,10 @@ static unsigned int
1158mpeg_poll(struct file *file, struct poll_table_struct *wait) 1162mpeg_poll(struct file *file, struct poll_table_struct *wait)
1159{ 1163{
1160 struct cx8802_fh *fh = file->private_data; 1164 struct cx8802_fh *fh = file->private_data;
1165 struct cx8802_dev *dev = fh->dev;
1166
1167 if (!dev->mpeg_active)
1168 blackbird_start_codec(file, fh);
1161 1169
1162 return videobuf_poll_stream(file, &fh->mpegq, wait); 1170 return videobuf_poll_stream(file, &fh->mpegq, wait);
1163} 1171}