@@ -293,6 +293,15 @@ all configurable using the following module options:
- 0: vmalloc
- 1: dma-contig
+- cache_hints:
+
+ user-space cache hints selection, default is 0. It specifies if the
+ device supports user-space cache (for MMAP queues only) and memory
+ consistency hints.
+
+ - 0: forbid hints
+ - 1: allow hints
+
Taken together, all these module options allow you to precisely customize
the driver behavior and test your application with all sorts of permutations.
It is also very suitable to emulate hardware that is not yet available, e.g.
@@ -169,6 +169,14 @@ MODULE_PARM_DESC(allocators, " memory allocator selection, default is 0.\n"
"\t\t 0 == vmalloc\n"
"\t\t 1 == dma-contig");
+static unsigned int cache_hints[VIVID_MAX_DEVS] = {
+ [0 ... (VIVID_MAX_DEVS - 1)] = 0
+};
+module_param_array(cache_hints, uint, NULL, 0444);
+MODULE_PARM_DESC(cache_hints, " user-space cache hints, default is 0.\n"
+ "\t\t 0 == forbid\n"
+ "\t\t 1 == allow");
+
static struct vivid_dev *vivid_devs[VIVID_MAX_DEVS];
const struct v4l2_rect vivid_min_rect = {
@@ -819,6 +827,7 @@ static int vivid_create_queue(struct vivid_dev *dev,
q->lock = &dev->mutex;
q->dev = dev->v4l2_dev.dev;
q->supports_requests = true;
+ dev->allow_cache_hints = (cache_hints[dev->inst] == 1);
return vb2_queue_init(q);
}
@@ -572,6 +572,7 @@ struct vivid_dev {
bool meta_pts;
bool meta_scr;
+ bool allow_cache_hints;
};
static inline bool vivid_is_webcam(const struct vivid_dev *dev)
@@ -34,6 +34,11 @@ static int meta_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
*nbuffers = 2 - vq->num_buffers;
*nplanes = 1;
+
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
return 0;
}
@@ -34,6 +34,11 @@ static int meta_out_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
*nbuffers = 2 - vq->num_buffers;
*nplanes = 1;
+
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
return 0;
}
@@ -211,9 +211,16 @@ static int sdr_cap_queue_setup(struct vb2_queue *vq,
unsigned *nbuffers, unsigned *nplanes,
unsigned sizes[], struct device *alloc_devs[])
{
+ struct vivid_dev *dev = vb2_get_drv_priv(vq);
+
/* 2 = max 16-bit sample returned */
sizes[0] = SDR_CAP_SAMPLES_PER_BUF * 2;
*nplanes = 1;
+
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
return 0;
}
@@ -27,6 +27,11 @@ static int touch_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
*nbuffers = 2 - vq->num_buffers;
*nplanes = 1;
+
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
return 0;
}
@@ -138,6 +138,11 @@ static int vbi_cap_queue_setup(struct vb2_queue *vq,
*nbuffers = 2 - vq->num_buffers;
*nplanes = 1;
+
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
return 0;
}
@@ -34,6 +34,11 @@ static int vbi_out_queue_setup(struct vb2_queue *vq,
*nbuffers = 2 - vq->num_buffers;
*nplanes = 1;
+
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
return 0;
}
@@ -129,6 +129,11 @@ static int vid_cap_queue_setup(struct vb2_queue *vq,
*nplanes = buffers;
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
+
dprintk(dev, 1, "%s: count=%d\n", __func__, *nbuffers);
for (p = 0; p < buffers; p++)
dprintk(dev, 1, "%s: size[%u]=%u\n", __func__, p, sizes[p]);
@@ -78,6 +78,11 @@ static int vid_out_queue_setup(struct vb2_queue *vq,
*nplanes = planes;
+ if (dev->allow_cache_hints && vq->memory == VB2_MEMORY_MMAP)
+ vq->allow_cache_hints = 1;
+ else
+ vq->allow_cache_hints = 0;
+
dprintk(dev, 1, "%s: count=%d\n", __func__, *nbuffers);
for (p = 0; p < planes; p++)
dprintk(dev, 1, "%s: size[%u]=%u\n", __func__, p, sizes[p]);
Add a cache_hints module param to control per-queue user space cache hints support. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> --- Documentation/admin-guide/media/vivid.rst | 9 +++++++++ drivers/media/test-drivers/vivid/vivid-core.c | 9 +++++++++ drivers/media/test-drivers/vivid/vivid-core.h | 1 + drivers/media/test-drivers/vivid/vivid-meta-cap.c | 5 +++++ drivers/media/test-drivers/vivid/vivid-meta-out.c | 5 +++++ drivers/media/test-drivers/vivid/vivid-sdr-cap.c | 7 +++++++ drivers/media/test-drivers/vivid/vivid-touch-cap.c | 5 +++++ drivers/media/test-drivers/vivid/vivid-vbi-cap.c | 5 +++++ drivers/media/test-drivers/vivid/vivid-vbi-out.c | 5 +++++ drivers/media/test-drivers/vivid/vivid-vid-cap.c | 5 +++++ drivers/media/test-drivers/vivid/vivid-vid-out.c | 5 +++++ 11 files changed, 61 insertions(+)