drivers/media/test-drivers/vivid/vivid-touch-cap.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vivid/vivid-touch-cap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vivid/vivid-touch-cap.c- Extension
.c- Size
- 8868 bytes
- Lines
- 337
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vivid-core.hvivid-kthread-touch.hvivid-vid-common.hvivid-touch-cap.h
Detected Declarations
function touch_cap_queue_setupfunction touch_cap_buf_preparefunction touch_cap_buf_queuefunction touch_cap_start_streamingfunction list_for_each_entry_safefunction touch_cap_stop_streamingfunction touch_cap_buf_request_completefunction vivid_enum_fmt_tchfunction vivid_g_fmt_tchfunction vivid_g_fmt_tch_mplanefunction vivid_g_parm_tchfunction vivid_enum_input_tchfunction vivid_g_input_tchfunction vivid_set_touchfunction vivid_s_input_tchfunction vivid_fill_buff_noisefunction get_random_pressurefunction vivid_tch_buf_setfunction vivid_fillbuff_tch
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* vivid-touch-cap.c - touch support functions.
*/
#include "vivid-core.h"
#include "vivid-kthread-touch.h"
#include "vivid-vid-common.h"
#include "vivid-touch-cap.h"
static int touch_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
unsigned int *nplanes, unsigned int sizes[],
struct device *alloc_devs[])
{
struct vivid_dev *dev = vb2_get_drv_priv(vq);
struct v4l2_pix_format *f = &dev->tch_format;
unsigned int size = f->sizeimage;
if (*nplanes) {
if (*nplanes != 1)
return -EINVAL;
return sizes[0] < size ? -EINVAL : 0;
}
*nplanes = 1;
sizes[0] = size;
return 0;
}
static int touch_cap_buf_prepare(struct vb2_buffer *vb)
{
struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
struct v4l2_pix_format *f = &dev->tch_format;
unsigned int size = f->sizeimage;
if (dev->buf_prepare_error) {
/*
* Error injection: test what happens if buf_prepare() returns
* an error.
*/
dev->buf_prepare_error = false;
return -EINVAL;
}
if (vb2_plane_size(vb, 0) < size) {
dprintk(dev, 1, "%s data will not fit into plane (%lu < %u)\n",
__func__, vb2_plane_size(vb, 0), size);
return -EINVAL;
}
vb2_set_plane_payload(vb, 0, size);
return 0;
}
static void touch_cap_buf_queue(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
struct vivid_buffer *buf = container_of(vbuf, struct vivid_buffer, vb);
vbuf->field = V4L2_FIELD_NONE;
spin_lock(&dev->slock);
list_add_tail(&buf->list, &dev->touch_cap_active);
spin_unlock(&dev->slock);
}
static int touch_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
{
struct vivid_dev *dev = vb2_get_drv_priv(vq);
int err;
dev->touch_cap_seq_count = 0;
if (dev->start_streaming_error) {
dev->start_streaming_error = false;
err = -EINVAL;
} else {
err = vivid_start_generating_touch_cap(dev);
}
if (err) {
struct vivid_buffer *buf, *tmp;
list_for_each_entry_safe(buf, tmp,
&dev->touch_cap_active, list) {
list_del(&buf->list);
vb2_buffer_done(&buf->vb.vb2_buf,
VB2_BUF_STATE_QUEUED);
}
}
return err;
}
Annotation
- Immediate include surface: `vivid-core.h`, `vivid-kthread-touch.h`, `vivid-vid-common.h`, `vivid-touch-cap.h`.
- Detected declarations: `function touch_cap_queue_setup`, `function touch_cap_buf_prepare`, `function touch_cap_buf_queue`, `function touch_cap_start_streaming`, `function list_for_each_entry_safe`, `function touch_cap_stop_streaming`, `function touch_cap_buf_request_complete`, `function vivid_enum_fmt_tch`, `function vivid_g_fmt_tch`, `function vivid_g_fmt_tch_mplane`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.