OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <dlfcn.h> | 5 #include <dlfcn.h> |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
9 #include <poll.h> | 9 #include <poll.h> |
10 #include <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 DCHECK_NE(decoder_state_, kUninitialized); | 1185 DCHECK_NE(decoder_state_, kUninitialized); |
1186 TRACE_EVENT0("Video Decoder", "EVDA::DequeueMfc"); | 1186 TRACE_EVENT0("Video Decoder", "EVDA::DequeueMfc"); |
1187 | 1187 |
1188 // Dequeue completed MFC input (VIDEO_OUTPUT) buffers, and recycle to the free | 1188 // Dequeue completed MFC input (VIDEO_OUTPUT) buffers, and recycle to the free |
1189 // list. | 1189 // list. |
1190 struct v4l2_buffer dqbuf; | 1190 struct v4l2_buffer dqbuf; |
1191 struct v4l2_plane planes[2]; | 1191 struct v4l2_plane planes[2]; |
1192 while (mfc_input_buffer_queued_count_ > 0) { | 1192 while (mfc_input_buffer_queued_count_ > 0) { |
1193 DCHECK(mfc_input_streamon_); | 1193 DCHECK(mfc_input_streamon_); |
1194 memset(&dqbuf, 0, sizeof(dqbuf)); | 1194 memset(&dqbuf, 0, sizeof(dqbuf)); |
1195 memset(planes, 0, sizeof(planes)); | |
1195 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1196 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
1196 dqbuf.memory = V4L2_MEMORY_MMAP; | 1197 dqbuf.memory = V4L2_MEMORY_MMAP; |
1198 dqbuf.m.planes = planes; | |
1199 dqbuf.length = 1; | |
1197 if (ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { | 1200 if (ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
1198 if (errno == EAGAIN) { | 1201 if (errno == EAGAIN) { |
1199 // EAGAIN if we're just out of buffers to dequeue. | 1202 // EAGAIN if we're just out of buffers to dequeue. |
1200 break; | 1203 break; |
1201 } | 1204 } |
1202 DPLOG(ERROR) << "DequeueMfc(): ioctl() failed: VIDIOC_DQBUF"; | 1205 DPLOG(ERROR) << "DequeueMfc(): ioctl() failed: VIDIOC_DQBUF"; |
1203 NOTIFY_ERROR(PLATFORM_FAILURE); | 1206 NOTIFY_ERROR(PLATFORM_FAILURE); |
1204 return; | 1207 return; |
1205 } | 1208 } |
1206 MfcInputRecord& input_record = mfc_input_buffer_map_[dqbuf.index]; | 1209 MfcInputRecord& input_record = mfc_input_buffer_map_[dqbuf.index]; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1318 DVLOG(3) << "DequeueGsc()"; | 1321 DVLOG(3) << "DequeueGsc()"; |
1319 DCHECK_EQ(decoder_thread_.message_loop(), MessageLoop::current()); | 1322 DCHECK_EQ(decoder_thread_.message_loop(), MessageLoop::current()); |
1320 DCHECK_NE(decoder_state_, kUninitialized); | 1323 DCHECK_NE(decoder_state_, kUninitialized); |
1321 DCHECK_NE(decoder_state_, kInitialized); | 1324 DCHECK_NE(decoder_state_, kInitialized); |
1322 DCHECK_NE(decoder_state_, kAfterReset); | 1325 DCHECK_NE(decoder_state_, kAfterReset); |
1323 TRACE_EVENT0("Video Decoder", "EVDA::DequeueGsc"); | 1326 TRACE_EVENT0("Video Decoder", "EVDA::DequeueGsc"); |
1324 | 1327 |
1325 // Dequeue completed GSC input (VIDEO_OUTPUT) buffers, and recycle to the free | 1328 // Dequeue completed GSC input (VIDEO_OUTPUT) buffers, and recycle to the free |
1326 // list. Also recycle the corresponding MFC output buffers at this time. | 1329 // list. Also recycle the corresponding MFC output buffers at this time. |
1327 struct v4l2_buffer dqbuf; | 1330 struct v4l2_buffer dqbuf; |
1331 struct v4l2_plane planes[2]; | |
1328 while (gsc_input_buffer_queued_count_ > 0) { | 1332 while (gsc_input_buffer_queued_count_ > 0) { |
1329 DCHECK(gsc_input_streamon_); | 1333 DCHECK(gsc_input_streamon_); |
1330 memset(&dqbuf, 0, sizeof(dqbuf)); | 1334 memset(&dqbuf, 0, sizeof(dqbuf)); |
1335 memset(planes, 0, sizeof(planes)); | |
1331 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1336 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
1332 dqbuf.memory = V4L2_MEMORY_DMABUF; | 1337 dqbuf.memory = V4L2_MEMORY_DMABUF; |
1338 dqbuf.m.planes = planes; | |
1339 dqbuf.length = 2; | |
1333 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { | 1340 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
1334 if (errno == EAGAIN) { | 1341 if (errno == EAGAIN) { |
1335 // EAGAIN if we're just out of buffers to dequeue. | 1342 // EAGAIN if we're just out of buffers to dequeue. |
1336 break; | 1343 break; |
1337 } | 1344 } |
1338 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; | 1345 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; |
1339 NOTIFY_ERROR(PLATFORM_FAILURE); | 1346 NOTIFY_ERROR(PLATFORM_FAILURE); |
1340 return; | 1347 return; |
1341 } | 1348 } |
1342 GscInputRecord& input_record = gsc_input_buffer_map_[dqbuf.index]; | 1349 GscInputRecord& input_record = gsc_input_buffer_map_[dqbuf.index]; |
1343 MfcOutputRecord& output_record = | 1350 MfcOutputRecord& output_record = |
1344 mfc_output_buffer_map_[input_record.mfc_output]; | 1351 mfc_output_buffer_map_[input_record.mfc_output]; |
1345 DCHECK(input_record.at_device); | 1352 DCHECK(input_record.at_device); |
1346 gsc_free_input_buffers_.push_back(dqbuf.index); | 1353 gsc_free_input_buffers_.push_back(dqbuf.index); |
1347 mfc_free_output_buffers_.push_back(input_record.mfc_output); | 1354 mfc_free_output_buffers_.push_back(input_record.mfc_output); |
1348 input_record.at_device = false; | 1355 input_record.at_device = false; |
1349 input_record.mfc_output = -1; | 1356 input_record.mfc_output = -1; |
1350 output_record.input_id = -1; | 1357 output_record.input_id = -1; |
1351 gsc_input_buffer_queued_count_--; | 1358 gsc_input_buffer_queued_count_--; |
1352 } | 1359 } |
1353 | 1360 |
1354 // Dequeue completed GSC output (VIDEO_CAPTURE) buffers, and send them off to | 1361 // Dequeue completed GSC output (VIDEO_CAPTURE) buffers, and send them off to |
1355 // the client. Don't recycle to its free list yet -- we can't do that until | 1362 // the client. Don't recycle to its free list yet -- we can't do that until |
1356 // ReusePictureBuffer() returns it to us. | 1363 // ReusePictureBuffer() returns it to us. |
1357 while (gsc_output_buffer_queued_count_ > 0) { | 1364 while (gsc_output_buffer_queued_count_ > 0) { |
1358 DCHECK(gsc_output_streamon_); | 1365 DCHECK(gsc_output_streamon_); |
1359 memset(&dqbuf, 0, sizeof(dqbuf)); | 1366 memset(&dqbuf, 0, sizeof(dqbuf)); |
1367 memset(planes, 0, sizeof(planes)); | |
1360 dqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 1368 dqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
1361 dqbuf.memory = V4L2_MEMORY_DMABUF; | 1369 dqbuf.memory = V4L2_MEMORY_DMABUF; |
1370 dqbuf.m.planes = planes; | |
1371 dqbuf.length = 1; | |
1362 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { | 1372 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
1363 if (errno == EAGAIN) { | 1373 if (errno == EAGAIN) { |
1364 // EAGAIN if we're just out of buffers to dequeue. | 1374 // EAGAIN if we're just out of buffers to dequeue. |
1365 break; | 1375 break; |
1366 } | 1376 } |
1367 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; | 1377 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; |
1368 NOTIFY_ERROR(PLATFORM_FAILURE); | 1378 NOTIFY_ERROR(PLATFORM_FAILURE); |
1369 return; | 1379 return; |
1370 } | 1380 } |
1371 GscOutputRecord& output_record = gsc_output_buffer_map_[dqbuf.index]; | 1381 GscOutputRecord& output_record = gsc_output_buffer_map_[dqbuf.index]; |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2049 control.id = V4L2_CID_HFLIP; | 2059 control.id = V4L2_CID_HFLIP; |
2050 control.value = 0; | 2060 control.value = 0; |
2051 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); | 2061 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); |
2052 | 2062 |
2053 memset(&control, 0, sizeof(control)); | 2063 memset(&control, 0, sizeof(control)); |
2054 control.id = V4L2_CID_VFLIP; | 2064 control.id = V4L2_CID_VFLIP; |
2055 control.value = 0; | 2065 control.value = 0; |
2056 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); | 2066 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); |
2057 | 2067 |
2058 memset(&control, 0, sizeof(control)); | 2068 memset(&control, 0, sizeof(control)); |
2059 control.id = V4L2_CID_GLOBAL_ALPHA; | 2069 control.id = V4L2_CID_ALPHA_COMPONENT; |
Pawel Osciak
2013/05/21 16:00:32
The driver in 3.4 doesn't handle this control, but
| |
2060 control.value = 255; | 2070 control.value = 255; |
2061 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); | 2071 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); |
2062 | 2072 |
2063 struct v4l2_requestbuffers reqbufs; | 2073 struct v4l2_requestbuffers reqbufs; |
2064 memset(&reqbufs, 0, sizeof(reqbufs)); | 2074 memset(&reqbufs, 0, sizeof(reqbufs)); |
2065 reqbufs.count = kGscInputBufferCount; | 2075 reqbufs.count = kGscInputBufferCount; |
2066 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 2076 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
2067 reqbufs.memory = V4L2_MEMORY_USERPTR; | 2077 reqbufs.memory = V4L2_MEMORY_USERPTR; |
2068 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs); | 2078 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs); |
2069 | 2079 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2217 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 2227 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
2218 reqbufs.memory = V4L2_MEMORY_DMABUF; | 2228 reqbufs.memory = V4L2_MEMORY_DMABUF; |
2219 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) | 2229 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) |
2220 DPLOG(ERROR) << "DestroyGscOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; | 2230 DPLOG(ERROR) << "DestroyGscOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; |
2221 | 2231 |
2222 gsc_output_buffer_map_.clear(); | 2232 gsc_output_buffer_map_.clear(); |
2223 gsc_free_output_buffers_.clear(); | 2233 gsc_free_output_buffers_.clear(); |
2224 } | 2234 } |
2225 | 2235 |
2226 } // namespace content | 2236 } // namespace content |
OLD | NEW |