xref: /aosp_15_r20/frameworks/native/services/inputflinger/reader/TouchVideoDevice.cpp (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright (C) 2018 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker  *
4*38e8c45fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker  *
8*38e8c45fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker  *
10*38e8c45fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker  * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker  */
16*38e8c45fSAndroid Build Coastguard Worker 
17*38e8c45fSAndroid Build Coastguard Worker #include "TouchVideoDevice.h"
18*38e8c45fSAndroid Build Coastguard Worker 
19*38e8c45fSAndroid Build Coastguard Worker #define LOG_TAG "TouchVideoDevice"
20*38e8c45fSAndroid Build Coastguard Worker 
21*38e8c45fSAndroid Build Coastguard Worker #include <errno.h>
22*38e8c45fSAndroid Build Coastguard Worker #include <fcntl.h>
23*38e8c45fSAndroid Build Coastguard Worker #include <inttypes.h>
24*38e8c45fSAndroid Build Coastguard Worker #include <linux/videodev2.h>
25*38e8c45fSAndroid Build Coastguard Worker #include <sys/ioctl.h>
26*38e8c45fSAndroid Build Coastguard Worker #include <sys/mman.h>
27*38e8c45fSAndroid Build Coastguard Worker #include <unistd.h>
28*38e8c45fSAndroid Build Coastguard Worker #include <iostream>
29*38e8c45fSAndroid Build Coastguard Worker 
30*38e8c45fSAndroid Build Coastguard Worker #include <android-base/stringprintf.h>
31*38e8c45fSAndroid Build Coastguard Worker #include <android-base/unique_fd.h>
32*38e8c45fSAndroid Build Coastguard Worker #include <log/log.h>
33*38e8c45fSAndroid Build Coastguard Worker 
34*38e8c45fSAndroid Build Coastguard Worker using android::base::StringPrintf;
35*38e8c45fSAndroid Build Coastguard Worker using android::base::unique_fd;
36*38e8c45fSAndroid Build Coastguard Worker 
37*38e8c45fSAndroid Build Coastguard Worker namespace android {
38*38e8c45fSAndroid Build Coastguard Worker 
TouchVideoDevice(int fd,std::string && name,std::string && devicePath,uint32_t height,uint32_t width,const std::array<const int16_t *,NUM_BUFFERS> & readLocations)39*38e8c45fSAndroid Build Coastguard Worker TouchVideoDevice::TouchVideoDevice(int fd, std::string&& name, std::string&& devicePath,
40*38e8c45fSAndroid Build Coastguard Worker                                    uint32_t height, uint32_t width,
41*38e8c45fSAndroid Build Coastguard Worker                                    const std::array<const int16_t*, NUM_BUFFERS>& readLocations)
42*38e8c45fSAndroid Build Coastguard Worker       : mFd(fd),
43*38e8c45fSAndroid Build Coastguard Worker         mName(std::move(name)),
44*38e8c45fSAndroid Build Coastguard Worker         mPath(std::move(devicePath)),
45*38e8c45fSAndroid Build Coastguard Worker         mHeight(height),
46*38e8c45fSAndroid Build Coastguard Worker         mWidth(width),
47*38e8c45fSAndroid Build Coastguard Worker         mReadLocations(readLocations) {
48*38e8c45fSAndroid Build Coastguard Worker     mFrames.reserve(MAX_QUEUE_SIZE);
49*38e8c45fSAndroid Build Coastguard Worker };
50*38e8c45fSAndroid Build Coastguard Worker 
create(std::string devicePath)51*38e8c45fSAndroid Build Coastguard Worker std::unique_ptr<TouchVideoDevice> TouchVideoDevice::create(std::string devicePath) {
52*38e8c45fSAndroid Build Coastguard Worker     unique_fd fd(open(devicePath.c_str(), O_RDWR | O_NONBLOCK | O_CLOEXEC));
53*38e8c45fSAndroid Build Coastguard Worker     if (fd.get() == INVALID_FD) {
54*38e8c45fSAndroid Build Coastguard Worker         ALOGE("Could not open video device %s: %s", devicePath.c_str(), strerror(errno));
55*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
56*38e8c45fSAndroid Build Coastguard Worker     }
57*38e8c45fSAndroid Build Coastguard Worker 
58*38e8c45fSAndroid Build Coastguard Worker     struct v4l2_capability cap;
59*38e8c45fSAndroid Build Coastguard Worker     int result = ioctl(fd.get(), VIDIOC_QUERYCAP, &cap);
60*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
61*38e8c45fSAndroid Build Coastguard Worker         ALOGE("VIDIOC_QUERYCAP failed: %s", strerror(errno));
62*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
63*38e8c45fSAndroid Build Coastguard Worker     }
64*38e8c45fSAndroid Build Coastguard Worker     if (!(cap.capabilities & V4L2_CAP_TOUCH)) {
65*38e8c45fSAndroid Build Coastguard Worker         ALOGE("Capability V4L2_CAP_TOUCH is not present, can't use device for heatmap data. "
66*38e8c45fSAndroid Build Coastguard Worker               "Make sure device specifies V4L2_CAP_TOUCH");
67*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
68*38e8c45fSAndroid Build Coastguard Worker     }
69*38e8c45fSAndroid Build Coastguard Worker     ALOGI("Opening video device: driver = %s, card = %s, bus_info = %s, version = %i", cap.driver,
70*38e8c45fSAndroid Build Coastguard Worker           cap.card, cap.bus_info, cap.version);
71*38e8c45fSAndroid Build Coastguard Worker     std::string name = reinterpret_cast<const char*>(cap.card);
72*38e8c45fSAndroid Build Coastguard Worker 
73*38e8c45fSAndroid Build Coastguard Worker     struct v4l2_input v4l2_input_struct;
74*38e8c45fSAndroid Build Coastguard Worker     v4l2_input_struct.index = 0;
75*38e8c45fSAndroid Build Coastguard Worker     result = ioctl(fd.get(), VIDIOC_ENUMINPUT, &v4l2_input_struct);
76*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
77*38e8c45fSAndroid Build Coastguard Worker         ALOGE("VIDIOC_ENUMINPUT failed: %s", strerror(errno));
78*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
79*38e8c45fSAndroid Build Coastguard Worker     }
80*38e8c45fSAndroid Build Coastguard Worker 
81*38e8c45fSAndroid Build Coastguard Worker     if (v4l2_input_struct.type != V4L2_INPUT_TYPE_TOUCH) {
82*38e8c45fSAndroid Build Coastguard Worker         ALOGE("Video device does not provide touch data. "
83*38e8c45fSAndroid Build Coastguard Worker               "Make sure device specifies V4L2_INPUT_TYPE_TOUCH.");
84*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
85*38e8c45fSAndroid Build Coastguard Worker     }
86*38e8c45fSAndroid Build Coastguard Worker 
87*38e8c45fSAndroid Build Coastguard Worker     struct v4l2_format v4l2_fmt;
88*38e8c45fSAndroid Build Coastguard Worker     v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
89*38e8c45fSAndroid Build Coastguard Worker     result = ioctl(fd.get(), VIDIOC_G_FMT, &v4l2_fmt);
90*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
91*38e8c45fSAndroid Build Coastguard Worker         ALOGE("VIDIOC_G_FMT failed: %s", strerror(errno));
92*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
93*38e8c45fSAndroid Build Coastguard Worker     }
94*38e8c45fSAndroid Build Coastguard Worker     const uint32_t height = v4l2_fmt.fmt.pix.height;
95*38e8c45fSAndroid Build Coastguard Worker     const uint32_t width = v4l2_fmt.fmt.pix.width;
96*38e8c45fSAndroid Build Coastguard Worker     ALOGI("Frame dimensions: height = %" PRIu32 " width = %" PRIu32, height, width);
97*38e8c45fSAndroid Build Coastguard Worker 
98*38e8c45fSAndroid Build Coastguard Worker     struct v4l2_requestbuffers req = {};
99*38e8c45fSAndroid Build Coastguard Worker     req.count = NUM_BUFFERS;
100*38e8c45fSAndroid Build Coastguard Worker     req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
101*38e8c45fSAndroid Build Coastguard Worker     req.memory = V4L2_MEMORY_MMAP;
102*38e8c45fSAndroid Build Coastguard Worker     // req.reserved is zeroed during initialization, which is required per v4l docs
103*38e8c45fSAndroid Build Coastguard Worker     result = ioctl(fd.get(), VIDIOC_REQBUFS, &req);
104*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
105*38e8c45fSAndroid Build Coastguard Worker         ALOGE("VIDIOC_REQBUFS failed: %s", strerror(errno));
106*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
107*38e8c45fSAndroid Build Coastguard Worker     }
108*38e8c45fSAndroid Build Coastguard Worker     if (req.count != NUM_BUFFERS) {
109*38e8c45fSAndroid Build Coastguard Worker         ALOGE("Requested %zu buffers, but driver responded with count=%i", NUM_BUFFERS, req.count);
110*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
111*38e8c45fSAndroid Build Coastguard Worker     }
112*38e8c45fSAndroid Build Coastguard Worker 
113*38e8c45fSAndroid Build Coastguard Worker     struct v4l2_buffer buf = {};
114*38e8c45fSAndroid Build Coastguard Worker     buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
115*38e8c45fSAndroid Build Coastguard Worker     buf.memory = V4L2_MEMORY_MMAP;
116*38e8c45fSAndroid Build Coastguard Worker     // buf.reserved and buf.reserved2 are zeroed during initialization, required per v4l docs
117*38e8c45fSAndroid Build Coastguard Worker     std::array<const int16_t*, NUM_BUFFERS> readLocations;
118*38e8c45fSAndroid Build Coastguard Worker     for (size_t i = 0; i < NUM_BUFFERS; i++) {
119*38e8c45fSAndroid Build Coastguard Worker         buf.index = i;
120*38e8c45fSAndroid Build Coastguard Worker         result = ioctl(fd.get(), VIDIOC_QUERYBUF, &buf);
121*38e8c45fSAndroid Build Coastguard Worker         if (result == -1) {
122*38e8c45fSAndroid Build Coastguard Worker             ALOGE("VIDIOC_QUERYBUF failed: %s", strerror(errno));
123*38e8c45fSAndroid Build Coastguard Worker             return nullptr;
124*38e8c45fSAndroid Build Coastguard Worker         }
125*38e8c45fSAndroid Build Coastguard Worker         if (buf.length != height * width * sizeof(int16_t)) {
126*38e8c45fSAndroid Build Coastguard Worker             ALOGE("Unexpected value of buf.length = %i (offset = %" PRIu32 ")", buf.length,
127*38e8c45fSAndroid Build Coastguard Worker                   buf.m.offset);
128*38e8c45fSAndroid Build Coastguard Worker             return nullptr;
129*38e8c45fSAndroid Build Coastguard Worker         }
130*38e8c45fSAndroid Build Coastguard Worker 
131*38e8c45fSAndroid Build Coastguard Worker         readLocations[i] = static_cast<const int16_t*>(
132*38e8c45fSAndroid Build Coastguard Worker                 mmap(nullptr /* start anywhere */, buf.length, PROT_READ /* required */,
133*38e8c45fSAndroid Build Coastguard Worker                      MAP_SHARED /* recommended */, fd.get(), buf.m.offset));
134*38e8c45fSAndroid Build Coastguard Worker         if (readLocations[i] == MAP_FAILED) {
135*38e8c45fSAndroid Build Coastguard Worker             ALOGE("%s: map failed: %s", __func__, strerror(errno));
136*38e8c45fSAndroid Build Coastguard Worker             return nullptr;
137*38e8c45fSAndroid Build Coastguard Worker         }
138*38e8c45fSAndroid Build Coastguard Worker     }
139*38e8c45fSAndroid Build Coastguard Worker 
140*38e8c45fSAndroid Build Coastguard Worker     enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
141*38e8c45fSAndroid Build Coastguard Worker     result = ioctl(fd.get(), VIDIOC_STREAMON, &type);
142*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
143*38e8c45fSAndroid Build Coastguard Worker         ALOGE("VIDIOC_STREAMON failed: %s", strerror(errno));
144*38e8c45fSAndroid Build Coastguard Worker         return nullptr;
145*38e8c45fSAndroid Build Coastguard Worker     }
146*38e8c45fSAndroid Build Coastguard Worker 
147*38e8c45fSAndroid Build Coastguard Worker     for (size_t i = 0; i < NUM_BUFFERS; i++) {
148*38e8c45fSAndroid Build Coastguard Worker         buf.index = i;
149*38e8c45fSAndroid Build Coastguard Worker         result = ioctl(fd.get(), VIDIOC_QBUF, &buf);
150*38e8c45fSAndroid Build Coastguard Worker         if (result == -1) {
151*38e8c45fSAndroid Build Coastguard Worker             ALOGE("VIDIOC_QBUF failed for buffer %zu: %s", i, strerror(errno));
152*38e8c45fSAndroid Build Coastguard Worker             return nullptr;
153*38e8c45fSAndroid Build Coastguard Worker         }
154*38e8c45fSAndroid Build Coastguard Worker     }
155*38e8c45fSAndroid Build Coastguard Worker     // Using 'new' to access a non-public constructor.
156*38e8c45fSAndroid Build Coastguard Worker     return std::unique_ptr<TouchVideoDevice>(new TouchVideoDevice(fd.release(), std::move(name),
157*38e8c45fSAndroid Build Coastguard Worker                                                                   std::move(devicePath), height,
158*38e8c45fSAndroid Build Coastguard Worker                                                                   width, readLocations));
159*38e8c45fSAndroid Build Coastguard Worker }
160*38e8c45fSAndroid Build Coastguard Worker 
readAndQueueFrames()161*38e8c45fSAndroid Build Coastguard Worker size_t TouchVideoDevice::readAndQueueFrames() {
162*38e8c45fSAndroid Build Coastguard Worker     std::vector<TouchVideoFrame> frames = readFrames();
163*38e8c45fSAndroid Build Coastguard Worker     const size_t numFrames = frames.size();
164*38e8c45fSAndroid Build Coastguard Worker     if (numFrames == 0) {
165*38e8c45fSAndroid Build Coastguard Worker         // Likely an error occurred
166*38e8c45fSAndroid Build Coastguard Worker         return 0;
167*38e8c45fSAndroid Build Coastguard Worker     }
168*38e8c45fSAndroid Build Coastguard Worker     // Concatenate the vectors, then clip up to maximum size allowed
169*38e8c45fSAndroid Build Coastguard Worker     mFrames.insert(mFrames.end(), std::make_move_iterator(frames.begin()),
170*38e8c45fSAndroid Build Coastguard Worker                    std::make_move_iterator(frames.end()));
171*38e8c45fSAndroid Build Coastguard Worker     if (mFrames.size() > MAX_QUEUE_SIZE) {
172*38e8c45fSAndroid Build Coastguard Worker         // A user-space grip suppression process may be processing the video frames, and holding
173*38e8c45fSAndroid Build Coastguard Worker         // back the input events. This could result in video frames being produced without the
174*38e8c45fSAndroid Build Coastguard Worker         // matching input events. Drop the oldest frame here to prepare for the next input event.
175*38e8c45fSAndroid Build Coastguard Worker         mFrames.erase(mFrames.begin(), mFrames.end() - MAX_QUEUE_SIZE);
176*38e8c45fSAndroid Build Coastguard Worker     }
177*38e8c45fSAndroid Build Coastguard Worker     return numFrames;
178*38e8c45fSAndroid Build Coastguard Worker }
179*38e8c45fSAndroid Build Coastguard Worker 
consumeFrames()180*38e8c45fSAndroid Build Coastguard Worker std::vector<TouchVideoFrame> TouchVideoDevice::consumeFrames() {
181*38e8c45fSAndroid Build Coastguard Worker     std::vector<TouchVideoFrame> frames = std::move(mFrames);
182*38e8c45fSAndroid Build Coastguard Worker     mFrames = {};
183*38e8c45fSAndroid Build Coastguard Worker     return frames;
184*38e8c45fSAndroid Build Coastguard Worker }
185*38e8c45fSAndroid Build Coastguard Worker 
readFrame()186*38e8c45fSAndroid Build Coastguard Worker std::optional<TouchVideoFrame> TouchVideoDevice::readFrame() {
187*38e8c45fSAndroid Build Coastguard Worker     struct v4l2_buffer buf = {};
188*38e8c45fSAndroid Build Coastguard Worker     buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
189*38e8c45fSAndroid Build Coastguard Worker     buf.memory = V4L2_MEMORY_MMAP;
190*38e8c45fSAndroid Build Coastguard Worker     int result = ioctl(mFd.get(), VIDIOC_DQBUF, &buf);
191*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
192*38e8c45fSAndroid Build Coastguard Worker         // EAGAIN means we've reached the end of the read buffer, so it's expected.
193*38e8c45fSAndroid Build Coastguard Worker         if (errno != EAGAIN) {
194*38e8c45fSAndroid Build Coastguard Worker             ALOGE("VIDIOC_DQBUF failed: %s", strerror(errno));
195*38e8c45fSAndroid Build Coastguard Worker         }
196*38e8c45fSAndroid Build Coastguard Worker         return std::nullopt;
197*38e8c45fSAndroid Build Coastguard Worker     }
198*38e8c45fSAndroid Build Coastguard Worker     if ((buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) != V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) {
199*38e8c45fSAndroid Build Coastguard Worker         // We use CLOCK_MONOTONIC for input events, so if the clocks don't match,
200*38e8c45fSAndroid Build Coastguard Worker         // we can't compare timestamps. Just log a warning, since this is a driver issue
201*38e8c45fSAndroid Build Coastguard Worker         ALOGW("The timestamp %lld.%lld was not acquired using CLOCK_MONOTONIC",
202*38e8c45fSAndroid Build Coastguard Worker               static_cast<long long>(buf.timestamp.tv_sec),
203*38e8c45fSAndroid Build Coastguard Worker               static_cast<long long>(buf.timestamp.tv_usec));
204*38e8c45fSAndroid Build Coastguard Worker     }
205*38e8c45fSAndroid Build Coastguard Worker     std::vector<int16_t> data(mHeight * mWidth);
206*38e8c45fSAndroid Build Coastguard Worker     const int16_t* readFrom = mReadLocations[buf.index];
207*38e8c45fSAndroid Build Coastguard Worker     std::copy(readFrom, readFrom + mHeight * mWidth, data.begin());
208*38e8c45fSAndroid Build Coastguard Worker     TouchVideoFrame frame(mHeight, mWidth, std::move(data), buf.timestamp);
209*38e8c45fSAndroid Build Coastguard Worker 
210*38e8c45fSAndroid Build Coastguard Worker     result = ioctl(mFd.get(), VIDIOC_QBUF, &buf);
211*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
212*38e8c45fSAndroid Build Coastguard Worker         ALOGE("VIDIOC_QBUF failed: %s", strerror(errno));
213*38e8c45fSAndroid Build Coastguard Worker     }
214*38e8c45fSAndroid Build Coastguard Worker     return std::make_optional(std::move(frame));
215*38e8c45fSAndroid Build Coastguard Worker }
216*38e8c45fSAndroid Build Coastguard Worker 
217*38e8c45fSAndroid Build Coastguard Worker /*
218*38e8c45fSAndroid Build Coastguard Worker  * This function should not be called unless buffer is ready! This must be checked with
219*38e8c45fSAndroid Build Coastguard Worker  * select, poll, epoll, or some other similar api first.
220*38e8c45fSAndroid Build Coastguard Worker  * The oldest frame will be at the beginning of the array.
221*38e8c45fSAndroid Build Coastguard Worker  */
readFrames()222*38e8c45fSAndroid Build Coastguard Worker std::vector<TouchVideoFrame> TouchVideoDevice::readFrames() {
223*38e8c45fSAndroid Build Coastguard Worker     std::vector<TouchVideoFrame> frames;
224*38e8c45fSAndroid Build Coastguard Worker     while (true) {
225*38e8c45fSAndroid Build Coastguard Worker         std::optional<TouchVideoFrame> frame = readFrame();
226*38e8c45fSAndroid Build Coastguard Worker         if (!frame) {
227*38e8c45fSAndroid Build Coastguard Worker             break;
228*38e8c45fSAndroid Build Coastguard Worker         }
229*38e8c45fSAndroid Build Coastguard Worker         frames.push_back(std::move(*frame));
230*38e8c45fSAndroid Build Coastguard Worker     }
231*38e8c45fSAndroid Build Coastguard Worker     return frames;
232*38e8c45fSAndroid Build Coastguard Worker }
233*38e8c45fSAndroid Build Coastguard Worker 
~TouchVideoDevice()234*38e8c45fSAndroid Build Coastguard Worker TouchVideoDevice::~TouchVideoDevice() {
235*38e8c45fSAndroid Build Coastguard Worker     enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
236*38e8c45fSAndroid Build Coastguard Worker     int result = ioctl(mFd.get(), VIDIOC_STREAMOFF, &type);
237*38e8c45fSAndroid Build Coastguard Worker     if (result == -1) {
238*38e8c45fSAndroid Build Coastguard Worker         ALOGE("VIDIOC_STREAMOFF failed: %s", strerror(errno));
239*38e8c45fSAndroid Build Coastguard Worker     }
240*38e8c45fSAndroid Build Coastguard Worker     for (const int16_t* buffer : mReadLocations) {
241*38e8c45fSAndroid Build Coastguard Worker         void* bufferAddress = static_cast<void*>(const_cast<int16_t*>(buffer));
242*38e8c45fSAndroid Build Coastguard Worker         result = munmap(bufferAddress, mHeight * mWidth * sizeof(int16_t));
243*38e8c45fSAndroid Build Coastguard Worker         if (result == -1) {
244*38e8c45fSAndroid Build Coastguard Worker             ALOGE("%s: Couldn't unmap: [%s]", __func__, strerror(errno));
245*38e8c45fSAndroid Build Coastguard Worker         }
246*38e8c45fSAndroid Build Coastguard Worker     }
247*38e8c45fSAndroid Build Coastguard Worker }
248*38e8c45fSAndroid Build Coastguard Worker 
dump() const249*38e8c45fSAndroid Build Coastguard Worker std::string TouchVideoDevice::dump() const {
250*38e8c45fSAndroid Build Coastguard Worker     return StringPrintf("Video device %s (%s) : height=%" PRIu32 ", width=%" PRIu32
251*38e8c45fSAndroid Build Coastguard Worker                         ", fd=%i, hasValidFd=%s",
252*38e8c45fSAndroid Build Coastguard Worker                         mName.c_str(), mPath.c_str(), mHeight, mWidth, mFd.get(),
253*38e8c45fSAndroid Build Coastguard Worker                         hasValidFd() ? "true" : "false");
254*38e8c45fSAndroid Build Coastguard Worker }
255*38e8c45fSAndroid Build Coastguard Worker 
256*38e8c45fSAndroid Build Coastguard Worker } // namespace android
257