aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pwc/pwc-if.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/pwc/pwc-if.c')
-rw-r--r--drivers/media/video/pwc/pwc-if.c54
1 files changed, 14 insertions, 40 deletions
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index b821065e3870..6f8b682b9245 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -966,36 +966,6 @@ void pwc_isoc_cleanup(struct pwc_device *pdev)
966 PWC_DEBUG_OPEN("<< pwc_isoc_cleanup()\n"); 966 PWC_DEBUG_OPEN("<< pwc_isoc_cleanup()\n");
967} 967}
968 968
969int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot)
970{
971 int ret, start;
972
973 /* Stop isoc stuff */
974 pwc_isoc_cleanup(pdev);
975 /* Reset parameters */
976 pwc_reset_buffers(pdev);
977 /* Try to set video mode... */
978 start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot);
979 if (ret) {
980 PWC_DEBUG_FLOW("pwc_set_video_mode attempt 1 failed.\n");
981 /* That failed... restore old mode (we know that worked) */
982 start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
983 if (start) {
984 PWC_DEBUG_FLOW("pwc_set_video_mode attempt 2 failed.\n");
985 }
986 }
987 if (start == 0)
988 {
989 if (pwc_isoc_init(pdev) < 0)
990 {
991 PWC_WARNING("Failed to restart ISOC transfers in pwc_try_video_mode.\n");
992 ret = -EAGAIN; /* let's try again, who knows if it works a second time */
993 }
994 }
995 pdev->drop_frames++; /* try to avoid garbage during switch */
996 return ret; /* Return original error code */
997}
998
999/********* 969/*********
1000 * sysfs 970 * sysfs
1001 *********/ 971 *********/
@@ -1175,7 +1145,7 @@ static int pwc_video_open(struct file *file)
1175 /* Set some defaults */ 1145 /* Set some defaults */
1176 pdev->vsnapshot = 0; 1146 pdev->vsnapshot = 0;
1177 1147
1178 /* Start iso pipe for video; first try the last used video size 1148 /* Set video size, first try the last used video size
1179 (or the default one); if that fails try QCIF/10 or QSIF/10; 1149 (or the default one); if that fails try QCIF/10 or QSIF/10;
1180 it that fails too, give up. 1150 it that fails too, give up.
1181 */ 1151 */
@@ -1202,15 +1172,6 @@ static int pwc_video_open(struct file *file)
1202 return i; 1172 return i;
1203 } 1173 }
1204 1174
1205 i = pwc_isoc_init(pdev);
1206 if (i) {
1207 PWC_DEBUG_OPEN("Failed to init ISOC stuff = %d.\n", i);
1208 pwc_isoc_cleanup(pdev);
1209 pwc_free_buffers(pdev);
1210 mutex_unlock(&pdev->modlock);
1211 return i;
1212 }
1213
1214 /* Initialize the webcam to sane value */ 1175 /* Initialize the webcam to sane value */
1215 pwc_set_brightness(pdev, 0x7fff); 1176 pwc_set_brightness(pdev, 0x7fff);
1216 pwc_set_agc(pdev, 1, 0); 1177 pwc_set_agc(pdev, 1, 0);
@@ -1325,6 +1286,11 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
1325 goto err_out; 1286 goto err_out;
1326 } 1287 }
1327 1288
1289 /* Start the stream (if not already started) */
1290 rv = pwc_isoc_init(pdev);
1291 if (rv)
1292 goto err_out;
1293
1328 /* In case we're doing partial reads, we don't have to wait for a frame */ 1294 /* In case we're doing partial reads, we don't have to wait for a frame */
1329 if (pdev->image_read_pos == 0) { 1295 if (pdev->image_read_pos == 0) {
1330 /* Do wait queueing according to the (doc)book */ 1296 /* Do wait queueing according to the (doc)book */
@@ -1394,6 +1360,7 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
1394{ 1360{
1395 struct video_device *vdev = file->private_data; 1361 struct video_device *vdev = file->private_data;
1396 struct pwc_device *pdev; 1362 struct pwc_device *pdev;
1363 int ret;
1397 1364
1398 if (vdev == NULL) 1365 if (vdev == NULL)
1399 return -EFAULT; 1366 return -EFAULT;
@@ -1401,6 +1368,13 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
1401 if (pdev == NULL) 1368 if (pdev == NULL)
1402 return -EFAULT; 1369 return -EFAULT;
1403 1370
1371 /* Start the stream (if not already started) */
1372 mutex_lock(&pdev->modlock);
1373 ret = pwc_isoc_init(pdev);
1374 mutex_unlock(&pdev->modlock);
1375 if (ret)
1376 return ret;
1377
1404 poll_wait(file, &pdev->frameq, wait); 1378 poll_wait(file, &pdev->frameq, wait);
1405 if (pdev->error_status) 1379 if (pdev->error_status)
1406 return POLLERR; 1380 return POLLERR;