Match video device name with input device name. There isn't an explicit API in v4l2 to get the video device name. The closest API to this is struct v4l2_capability.card that is obtained via VIDIOC_QUERYCAP ioctl. Currently, the "card" field is set to the touch driver name, which may (and usually does) not correspond to the input device name. To fix this, add an optional reference to the parent input device. The decision was made here to just provide an input device reference instead of just copying the string name into the v4l2 struct. The rationale is that the logic is simpler, the nullness check can be more meaningful (if not specified, can default to driver name), and it is more efficient to just keep a pointer around instead of worrying about copying strings, allocating the proper amount of space, etc. Test: tested with C1. With additional (unreleased) code to match the input device with a video device in inputflinger, able to correctly receive the video frames and pass that on to higher layers of the stack. Bug: 111480215 Signed-Off-By: Siarhei Vishniakou <svv@google.com> Change-Id: I2b84a6d5d06a0cb88ab0ae03ec1fa32c1a1e7405
47 lines
1.3 KiB
C
47 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#include <media/v4l2-device.h>
|
|
#include <media/v4l2-ioctl.h>
|
|
#include <media/videobuf2-v4l2.h>
|
|
|
|
typedef int16_t strength_t;
|
|
|
|
struct v4l2_heatmap {
|
|
struct device *parent_dev;
|
|
/* Can be NULL. Used to get the input device name */
|
|
struct input_dev *input_dev;
|
|
struct v4l2_device device;
|
|
struct v4l2_pix_format format;
|
|
struct video_device vdev;
|
|
struct vb2_queue queue;
|
|
struct mutex lock;
|
|
unsigned int input_index;
|
|
|
|
size_t width;
|
|
size_t height;
|
|
|
|
struct v4l2_fract timeperframe;
|
|
|
|
/* Used to protect access to the buffer queue */
|
|
spinlock_t heatmap_lock;
|
|
/* guarded by heatmap_lock */
|
|
struct list_head heatmap_buffer_list;
|
|
|
|
/*
|
|
* Function read_frame must be provided by the driver
|
|
* It should return true on successful heatmap read
|
|
* and false on failure
|
|
*/
|
|
bool (*read_frame)(struct v4l2_heatmap *v4l2, strength_t *data);
|
|
};
|
|
|
|
int heatmap_probe(struct v4l2_heatmap *v4l2);
|
|
void heatmap_remove(struct v4l2_heatmap *v4l2);
|
|
/**
|
|
* Read the heatmap and populate an available buffer with data.
|
|
* The timestamp provided to this function will be used as the frame time.
|
|
* Designed to be called from interrupt context.
|
|
* This function should be called from the driver. Internally, it will call
|
|
* read_frame(..) provided by the driver to read the actual data.
|
|
*/
|
|
void heatmap_read(struct v4l2_heatmap *v4l2, uint64_t timestamp); |