Chromium Code Reviews| 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 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1187 DCHECK_NE(decoder_state_, kUninitialized); | 1187 DCHECK_NE(decoder_state_, kUninitialized); |
| 1188 TRACE_EVENT0("Video Decoder", "EVDA::DequeueMfc"); | 1188 TRACE_EVENT0("Video Decoder", "EVDA::DequeueMfc"); |
| 1189 | 1189 |
| 1190 // Dequeue completed MFC input (VIDEO_OUTPUT) buffers, and recycle to the free | 1190 // Dequeue completed MFC input (VIDEO_OUTPUT) buffers, and recycle to the free |
| 1191 // list. | 1191 // list. |
| 1192 struct v4l2_buffer dqbuf; | 1192 struct v4l2_buffer dqbuf; |
| 1193 struct v4l2_plane planes[2]; | 1193 struct v4l2_plane planes[2]; |
| 1194 while (mfc_input_buffer_queued_count_ > 0) { | 1194 while (mfc_input_buffer_queued_count_ > 0) { |
| 1195 DCHECK(mfc_input_streamon_); | 1195 DCHECK(mfc_input_streamon_); |
| 1196 memset(&dqbuf, 0, sizeof(dqbuf)); | 1196 memset(&dqbuf, 0, sizeof(dqbuf)); |
| 1197 memset(planes, 0, sizeof(planes)); | |
| 1197 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1198 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1198 dqbuf.memory = V4L2_MEMORY_MMAP; | 1199 dqbuf.memory = V4L2_MEMORY_MMAP; |
| 1200 dqbuf.m.planes = planes; | |
| 1201 dqbuf.length = 1; | |
| 1199 if (ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { | 1202 if (ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
| 1200 if (errno == EAGAIN) { | 1203 if (errno == EAGAIN) { |
| 1201 // EAGAIN if we're just out of buffers to dequeue. | 1204 // EAGAIN if we're just out of buffers to dequeue. |
| 1202 break; | 1205 break; |
| 1203 } | 1206 } |
| 1204 DPLOG(ERROR) << "DequeueMfc(): ioctl() failed: VIDIOC_DQBUF"; | 1207 DPLOG(ERROR) << "DequeueMfc(): ioctl() failed: VIDIOC_DQBUF"; |
| 1205 NOTIFY_ERROR(PLATFORM_FAILURE); | 1208 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 1206 return; | 1209 return; |
| 1207 } | 1210 } |
| 1208 MfcInputRecord& input_record = mfc_input_buffer_map_[dqbuf.index]; | 1211 MfcInputRecord& input_record = mfc_input_buffer_map_[dqbuf.index]; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1320 DVLOG(3) << "DequeueGsc()"; | 1323 DVLOG(3) << "DequeueGsc()"; |
| 1321 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 1324 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| 1322 DCHECK_NE(decoder_state_, kUninitialized); | 1325 DCHECK_NE(decoder_state_, kUninitialized); |
| 1323 DCHECK_NE(decoder_state_, kInitialized); | 1326 DCHECK_NE(decoder_state_, kInitialized); |
| 1324 DCHECK_NE(decoder_state_, kAfterReset); | 1327 DCHECK_NE(decoder_state_, kAfterReset); |
| 1325 TRACE_EVENT0("Video Decoder", "EVDA::DequeueGsc"); | 1328 TRACE_EVENT0("Video Decoder", "EVDA::DequeueGsc"); |
| 1326 | 1329 |
| 1327 // Dequeue completed GSC input (VIDEO_OUTPUT) buffers, and recycle to the free | 1330 // Dequeue completed GSC input (VIDEO_OUTPUT) buffers, and recycle to the free |
| 1328 // list. Also recycle the corresponding MFC output buffers at this time. | 1331 // list. Also recycle the corresponding MFC output buffers at this time. |
| 1329 struct v4l2_buffer dqbuf; | 1332 struct v4l2_buffer dqbuf; |
| 1333 struct v4l2_plane planes[2]; | |
| 1330 while (gsc_input_buffer_queued_count_ > 0) { | 1334 while (gsc_input_buffer_queued_count_ > 0) { |
| 1331 DCHECK(gsc_input_streamon_); | 1335 DCHECK(gsc_input_streamon_); |
| 1332 memset(&dqbuf, 0, sizeof(dqbuf)); | 1336 memset(&dqbuf, 0, sizeof(dqbuf)); |
| 1337 memset(planes, 0, sizeof(planes)); | |
| 1333 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1338 dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1334 dqbuf.memory = V4L2_MEMORY_DMABUF; | 1339 dqbuf.memory = V4L2_MEMORY_DMABUF; |
| 1340 dqbuf.m.planes = planes; | |
| 1341 dqbuf.length = 2; | |
| 1335 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { | 1342 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
| 1336 if (errno == EAGAIN) { | 1343 if (errno == EAGAIN) { |
| 1337 // EAGAIN if we're just out of buffers to dequeue. | 1344 // EAGAIN if we're just out of buffers to dequeue. |
| 1338 break; | 1345 break; |
| 1339 } | 1346 } |
| 1340 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; | 1347 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; |
| 1341 NOTIFY_ERROR(PLATFORM_FAILURE); | 1348 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 1342 return; | 1349 return; |
| 1343 } | 1350 } |
| 1344 GscInputRecord& input_record = gsc_input_buffer_map_[dqbuf.index]; | 1351 GscInputRecord& input_record = gsc_input_buffer_map_[dqbuf.index]; |
| 1345 MfcOutputRecord& output_record = | 1352 MfcOutputRecord& output_record = |
| 1346 mfc_output_buffer_map_[input_record.mfc_output]; | 1353 mfc_output_buffer_map_[input_record.mfc_output]; |
| 1347 DCHECK(input_record.at_device); | 1354 DCHECK(input_record.at_device); |
| 1348 gsc_free_input_buffers_.push_back(dqbuf.index); | 1355 gsc_free_input_buffers_.push_back(dqbuf.index); |
| 1349 mfc_free_output_buffers_.push_back(input_record.mfc_output); | 1356 mfc_free_output_buffers_.push_back(input_record.mfc_output); |
| 1350 input_record.at_device = false; | 1357 input_record.at_device = false; |
| 1351 input_record.mfc_output = -1; | 1358 input_record.mfc_output = -1; |
| 1352 output_record.input_id = -1; | 1359 output_record.input_id = -1; |
| 1353 gsc_input_buffer_queued_count_--; | 1360 gsc_input_buffer_queued_count_--; |
| 1354 } | 1361 } |
| 1355 | 1362 |
| 1356 // Dequeue completed GSC output (VIDEO_CAPTURE) buffers, and send them off to | 1363 // Dequeue completed GSC output (VIDEO_CAPTURE) buffers, and send them off to |
| 1357 // the client. Don't recycle to its free list yet -- we can't do that until | 1364 // the client. Don't recycle to its free list yet -- we can't do that until |
| 1358 // ReusePictureBuffer() returns it to us. | 1365 // ReusePictureBuffer() returns it to us. |
| 1359 while (gsc_output_buffer_queued_count_ > 0) { | 1366 while (gsc_output_buffer_queued_count_ > 0) { |
| 1360 DCHECK(gsc_output_streamon_); | 1367 DCHECK(gsc_output_streamon_); |
| 1361 memset(&dqbuf, 0, sizeof(dqbuf)); | 1368 memset(&dqbuf, 0, sizeof(dqbuf)); |
| 1369 memset(planes, 0, sizeof(planes)); | |
| 1362 dqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 1370 dqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1363 dqbuf.memory = V4L2_MEMORY_DMABUF; | 1371 dqbuf.memory = V4L2_MEMORY_DMABUF; |
| 1372 dqbuf.m.planes = planes; | |
| 1373 dqbuf.length = 1; | |
| 1364 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { | 1374 if (ioctl(gsc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
| 1365 if (errno == EAGAIN) { | 1375 if (errno == EAGAIN) { |
| 1366 // EAGAIN if we're just out of buffers to dequeue. | 1376 // EAGAIN if we're just out of buffers to dequeue. |
| 1367 break; | 1377 break; |
| 1368 } | 1378 } |
| 1369 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; | 1379 DPLOG(ERROR) << "DequeueGsc(): ioctl() failed: VIDIOC_DQBUF"; |
| 1370 NOTIFY_ERROR(PLATFORM_FAILURE); | 1380 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 1371 return; | 1381 return; |
| 1372 } | 1382 } |
| 1373 GscOutputRecord& output_record = gsc_output_buffer_map_[dqbuf.index]; | 1383 GscOutputRecord& output_record = gsc_output_buffer_map_[dqbuf.index]; |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2053 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); | 2063 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); |
| 2054 | 2064 |
| 2055 memset(&control, 0, sizeof(control)); | 2065 memset(&control, 0, sizeof(control)); |
| 2056 control.id = V4L2_CID_VFLIP; | 2066 control.id = V4L2_CID_VFLIP; |
| 2057 control.value = 0; | 2067 control.value = 0; |
| 2058 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); | 2068 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); |
| 2059 | 2069 |
| 2060 memset(&control, 0, sizeof(control)); | 2070 memset(&control, 0, sizeof(control)); |
| 2061 control.id = V4L2_CID_GLOBAL_ALPHA; | 2071 control.id = V4L2_CID_GLOBAL_ALPHA; |
| 2062 control.value = 255; | 2072 control.value = 255; |
| 2063 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); | 2073 if (HANDLE_EINTR(ioctl(gsc_fd_, VIDIOC_S_CTRL, &control)) != 0) { |
|
sheu
2013/05/23 23:03:04
This is the 3.4/3.8 compatibility bit.
| |
| 2074 memset(&control, 0, sizeof(control)); | |
| 2075 control.id = V4L2_CID_ALPHA_COMPONENT; | |
| 2076 control.value = 255; | |
| 2077 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); | |
| 2078 } | |
| 2064 | 2079 |
| 2065 struct v4l2_requestbuffers reqbufs; | 2080 struct v4l2_requestbuffers reqbufs; |
| 2066 memset(&reqbufs, 0, sizeof(reqbufs)); | 2081 memset(&reqbufs, 0, sizeof(reqbufs)); |
| 2067 reqbufs.count = kGscInputBufferCount; | 2082 reqbufs.count = kGscInputBufferCount; |
| 2068 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 2083 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 2069 reqbufs.memory = V4L2_MEMORY_USERPTR; | 2084 reqbufs.memory = V4L2_MEMORY_USERPTR; |
| 2070 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs); | 2085 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs); |
| 2071 | 2086 |
| 2072 gsc_input_buffer_map_.resize(reqbufs.count); | 2087 gsc_input_buffer_map_.resize(reqbufs.count); |
| 2073 for (size_t i = 0; i < gsc_input_buffer_map_.size(); ++i) { | 2088 for (size_t i = 0; i < gsc_input_buffer_map_.size(); ++i) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2219 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 2234 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 2220 reqbufs.memory = V4L2_MEMORY_DMABUF; | 2235 reqbufs.memory = V4L2_MEMORY_DMABUF; |
| 2221 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) | 2236 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) |
| 2222 DPLOG(ERROR) << "DestroyGscOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; | 2237 DPLOG(ERROR) << "DestroyGscOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; |
| 2223 | 2238 |
| 2224 gsc_output_buffer_map_.clear(); | 2239 gsc_output_buffer_map_.clear(); |
| 2225 gsc_free_output_buffers_.clear(); | 2240 gsc_free_output_buffers_.clear(); |
| 2226 } | 2241 } |
| 2227 | 2242 |
| 2228 } // namespace content | 2243 } // namespace content |
| OLD | NEW |