aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/soc_camera.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/soc_camera.c')
-rw-r--r--drivers/media/video/soc_camera.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index ddb4c091dedc..3fb533c4d334 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -41,6 +41,11 @@
41#define DEFAULT_WIDTH 640 41#define DEFAULT_WIDTH 640
42#define DEFAULT_HEIGHT 480 42#define DEFAULT_HEIGHT 480
43 43
44#define is_streaming(ici, icd) \
45 (((ici)->ops->init_videobuf) ? \
46 (icd)->vb_vidq.streaming : \
47 vb2_is_streaming(&(icd)->vb2_vidq))
48
44static LIST_HEAD(hosts); 49static LIST_HEAD(hosts);
45static LIST_HEAD(devices); 50static LIST_HEAD(devices);
46static DEFINE_MUTEX(list_lock); /* Protects the list of hosts */ 51static DEFINE_MUTEX(list_lock); /* Protects the list of hosts */
@@ -662,7 +667,7 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv,
662 if (icd->streamer && icd->streamer != file) 667 if (icd->streamer && icd->streamer != file)
663 return -EBUSY; 668 return -EBUSY;
664 669
665 if (icd->vb_vidq.bufs[0]) { 670 if (is_streaming(to_soc_camera_host(icd->dev.parent), icd)) {
666 dev_err(&icd->dev, "S_FMT denied: queue initialised\n"); 671 dev_err(&icd->dev, "S_FMT denied: queue initialised\n");
667 return -EBUSY; 672 return -EBUSY;
668 } 673 }
@@ -903,14 +908,17 @@ static int soc_camera_s_crop(struct file *file, void *fh,
903 if (ret < 0) { 908 if (ret < 0) {
904 dev_err(&icd->dev, 909 dev_err(&icd->dev,
905 "S_CROP denied: getting current crop failed\n"); 910 "S_CROP denied: getting current crop failed\n");
906 } else if (icd->vb_vidq.bufs[0] && 911 } else if ((a->c.width == current_crop.c.width &&
907 (a->c.width != current_crop.c.width || 912 a->c.height == current_crop.c.height) ||
908 a->c.height != current_crop.c.height)) { 913 !is_streaming(ici, icd)) {
914 /* same size or not streaming - use .set_crop() */
915 ret = ici->ops->set_crop(icd, a);
916 } else if (ici->ops->set_livecrop) {
917 ret = ici->ops->set_livecrop(icd, a);
918 } else {
909 dev_err(&icd->dev, 919 dev_err(&icd->dev,
910 "S_CROP denied: queue initialised and sizes differ\n"); 920 "S_CROP denied: queue initialised and sizes differ\n");
911 ret = -EBUSY; 921 ret = -EBUSY;
912 } else {
913 ret = ici->ops->set_crop(icd, a);
914 } 922 }
915 923
916 return ret; 924 return ret;