Commit graph

192 commits

Author SHA1 Message Date
Treehugger Robot
3d7f02b0ee Merge "camera: add info about current status into README" 2019-01-28 21:20:03 +00:00
Treehugger Robot
06ea58579b Merge "Revert "Disable XOM in camera.v4l2."" 2019-01-16 00:41:52 +00:00
Ivan Lozano
2bf3340e78 Revert "Disable XOM in camera.v4l2."
This reverts commit 7c7c62db25.

Reason for revert: libjpeg-turbo has been updated with XOM compatibility.

Change-Id: If1daae895f9cfe08c03169ed2546c81c51a94117
2019-01-15 22:17:46 +00:00
Ari Hausman-Cohen
8c3812f639 Merge "camera: add a lock for the request tracker" 2019-01-10 19:01:26 +00:00
Treehugger Robot
9dae907ea0 Merge "camera: remove redundant and unnecessary includes" 2019-01-10 00:39:43 +00:00
Treehugger Robot
3664a25aa7 Merge "camera: allow to get size of JPEG after conversion" 2019-01-09 01:23:12 +00:00
Ivan Lozano
7c7c62db25 Disable XOM in camera.v4l2.
Disable execute-only memory layouts in camera.v4l2.

This relies on libjpeg_static_ndk, which contains some data mixed into
code and thus requires a readable .text.

Bug: 77958880
Test: Built the library, checked the program headers with readelf.

Change-Id: I5646b8c5e9a0ad151663df29f019b5a84db4b15c
2018-11-29 14:37:38 -08:00
Sergii Piatakov
688d3bf720 camera: allow to get size of JPEG after conversion
The member function `ImageProcessor::GetConvertedSize` is called by the
`ImageProcessor::ConvertFormat` every time when conversion is performed.
But for JPEG destination format it leads to error. It is proposed to add
the handling of the JPEG format with postponed size calculation.

Test: try to take a picture via camera with YUYV output format.
Change-Id: I1ec564e2434361c82b5d93348511116494249f06
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-10-22 09:37:07 +03:00
Sergii Piatakov
16d9135088 camera: initialize smart pointer before usage
Test: try to scale image and get SIGSEGV crash of the `cameraserver`
      in the `CachedFrame` class.
Change-Id: I17ab13f7c9e7fc84cd38f89dce30e6e5e0535cc7
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-10-22 08:59:57 +03:00
Sergii Piatakov
b8f073fb8a camera: remove redundant and unnecessary includes
Remove unused or already included headers. Sort and format includes
accordind to the "Google C++ Style Guide". Replace C-headers by C++
analog when it's possible.

Test: build
Change-Id: I19fa6abb5bb68e0257c9c933e68f42f92b394ce7
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-10-18 13:39:48 +03:00
Sergii Piatakov
082a87bc0b camera: add info about current status into README
Test: n/a.
Change-Id: I9e62a8a6d8c04dac2c36bc483f011cb75ce20b2e
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-10-17 10:12:31 +03:00
Sergii Piatakov
48ac84b8be camera: add a lock for the request tracker
The request tracker manages "in flights" buffers and frames. These
two containers are modified by calling the tracker's member functions.
Such functions are called from at least three threads: (see
`v4l2_camera.cpp` for more details):
 - "main" thread;
 - separate buffer enqueue thread ("Enqueue buffers");
 - separate buffer dequeue thread ("Dequeue buffers").
It is proposed to introduce additional mutex for the request tracker
to prevent a race condition.

An alternative approach is introducing an additional mutex for the
shared containers inside the `RequresTracker` class. But such approach
requires more changes and may lead to problems with design in the
future.

This commit contains a few additional changes which are not directly
related to the topic:
 - as far as more than one local lock is used all of them are renamed;
 - the `mFlushLock` member is removed because it is completely covered
   by the new mutex.

Test: try to use a camera with more than one buffer and get SIGSEGV
      crash of the `cameraserver` in the `RequestTracker` class.
Change-Id: I2c1901722289cee9f0cb05a11a4dabe70d18f2ba
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-10-17 09:52:09 +03:00
Sergii Piatakov
028763d929 camera: avoid narrowing of the ioctl request
The `ioctl` take request of the `unsinged long` type but current
implementation narrows it up to `int`.

Test: if add something like this into `IoctlLocked`:
      ```
      switch (request) {
        case VIDIOC_QBUF: break;
        default:;
      }
      ```
      the following error is appears: "error: case value evaluates
      to 3227014671, which cannot be narrowed to type 'int'
      [-Wc++11-narrowing]".
Change-Id: Icb1c99e082feb0c019393205a4b0b717ddc09c05
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-10-10 17:49:02 +03:00
Sergii Piatakov
628e9d98e7 camera: replace -Wno-error flag with -Werror
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: Ib7227f189cdcd52698ef1a70b1ad03b2351cb55f
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-13 09:00:05 +03:00
Sergii Piatakov
de617f0677 camera: fix -Wunused-function compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I96926932e7b11230d6c22fb081a89946f670511e
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:39:32 +03:00
Sergii Piatakov
21583568a8 camera: fix -Wpessimizing-move compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I464761128a09d90415ee6ac1ef1244391edb0b54
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:39:32 +03:00
Sergii Piatakov
6a4d4d59bc camera: fix -Wmissing-field-initializers compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I2c17b1e40b29ac400e0a950a9cd96d7f9404ea32
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:39:32 +03:00
Sergii Piatakov
64e7f2013b camera: fix -Wsign-compare compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I47ee9e39c3bfee7927f4e57dfec459714c959e14
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:39:23 +03:00
Sergii Piatakov
416b6d263f camera: fix -Wunused-variable compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I2755278b739db0bb746a78d0b66e1f644a44ff19
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:37:02 +03:00
Sergii Piatakov
752836d7a6 camera: fix -Wunused-private-field compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I113e14a4296e098a6a04068262186aa8cb81fba7
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:37:02 +03:00
Sergii Piatakov
1bd0addfc9 camera: fix -Wreorder compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I02cbe738fb7484e3a1d55712b0f0a55037e181e1
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:37:02 +03:00
Sergii Piatakov
4d3eb7a33f camera: fix -Wunused-parameter compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: I1bfd688902c78fe69bfbee3bacc73c25a5ef6c5c
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:37:02 +03:00
Sergii Piatakov
a01d1f8233 camera: fix -Wformat compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: Ib1d1fc2de98436dd7e9d15ab324789725bb2002e
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:36:42 +03:00
Sergii Piatakov
2ad591f9ea camera: fix -Wmacro-redefined compiler warnings
Test: add `USE_CAMERA_V4L2_HAL := true` to
      hardware/libhardware/modules/camera/3_4/Android.mk and build
      mmm hardware/libhardware/modules/camera/3_4
Change-Id: Ida00d842007e2a589907bc4fd1887076fd8b5b2a
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2018-08-10 14:16:05 +03:00
Dmitry Shmidt
9df082e933 camera 3_4: Fix compilation errors
Compile Error:
hardware/libhardware/modules/camera/3_4/camera.cpp:502:9: error: non-constant-expression cannot be narrowed from type 'std::__1::vector<camera3_stream_buffer, std::__1::allocator<camera3_stream_buffer> >::size_type' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
        request->output_buffers.size(),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Test: Add to device.mk
        USE_CAMERA_V4L2_HAL := true
        PRODUCT_PACKAGES += camera.v4l2
      mma

Change-Id: Ia6bbd6bac06540214d2c6167a8826f3f4c946e57
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2018-01-24 12:34:00 -08:00
Prashanth Swaminathan
28e0f76353 v4l2 camera: port ARC++ image processing code
Utiltizes ARC++ image processing code to perform the conversion between
the camera format and the requested format from the framework. In order
to support USB devices which may not implement the required formats,
conversion between YUYV/MJPEG to the request format is done on-the-fly.

TEST: All existing unit tests pass. Tested manually with the camera
sample APK, preview/video/capture in both JPEG and YUV formats. Tested
on the RPi v2 Camera, the Logitech C270 and the 180 degree Fisheye USB
camera.
Bug: 37708856, Bug: 69983918
Exempt-From-Owner-Approval: This HAL is owned by AT team.
Change-Id: I1a54581d1170fa3270036ec366fb613fe587a094
2018-01-10 12:39:23 +09:00
TreeHugger Robot
f78d716b89 Merge "Support native camera resolutions" 2018-01-04 06:31:28 +00:00
Josh Gao
9eb0a7b073 Merge "Don't TEMP_FAILURE_RETRY on close." am: e1c003dc11 am: 7f4b73fb1a
am: 619653d7b1

Change-Id: I1f896a59da33be27a5d81362a6a1897f0ec277cf
2017-12-29 00:29:48 +00:00
Treehugger Robot
e1c003dc11 Merge "Don't TEMP_FAILURE_RETRY on close." 2017-12-29 00:19:21 +00:00
Josh Gao
09a3af5e11 Don't TEMP_FAILURE_RETRY on close.
close always succeeds, even if it was interrupted and "fails" with
EINTR. Retrying will either close a nonexistent fd or stomp on another
thread's newly opened file descriptor.

Bug: http://b/20501816
Test: treehugger
Change-Id: I706d5e8027e60b13f23f9488fdf5cf7cef7b3d3b
2017-12-28 14:21:32 -08:00
Dan Willemsen
844c74a750 Merge "Convert to Android.bp" am: 90e0a80af3 am: 243ba5e7b2
am: 90955e6a6a

Change-Id: I8e4e8c784b4e6630b7d062c4238d8c885111df30
2017-12-28 19:38:41 +00:00
Dan Willemsen
86e247ae89 Convert to Android.bp
See build/soong/README.md for more information

Test: mmma hardware/libhardware
Change-Id: Ibb7e2af9d55f581e951d8996cea5e52cd0766b04
2017-12-27 11:05:29 -08:00
Jaesung Chung
932d4dddd9 Support native camera resolutions
This CL makes camera HAL support native camera resoultions up to
3280x2464, which is the maximum camera resolution of RPi3's camera
module version two.

Bug: 69983703
Test: Verified with ThingsCameraQA.apk
Exempt-From-Owner-Approval: V4L2 camera HAL is owned by iot team.
Change-Id: I303e763e87bdfc5ae81d398aac8be0730e57b05d
2017-12-26 03:09:59 +00:00
Chih-hung Hsieh
fbb4c361fb Merge "Allow warnings in modules/camera/3_4." am: 1d83294190 am: 37724db429
am: 94202cf12e

Change-Id: I714a5fcd60d00f2811d15be614229fa25d50ef85
2017-12-20 02:06:55 +00:00
Chih-Hung Hsieh
87ef6ef33d Allow warnings in modules/camera/3_4.
* This directory still has many warnings to fix.

Bug: 66996870
Test: normal build
Change-Id: I0e05b78eca9d58dc9081bb3810f5ccabadfc21a7
Exempt-From-Owner-Approval: quick fix for broken build
2017-12-19 17:52:51 -08:00
Dan Albert
332da11294 Include what you use.
Test: mma
Bug: None
Change-Id: I024a2ee0af142c1bb923fcefd54b8b2077107476
Exempt-From-Owner-Approval: trivial cleanup
2017-12-12 15:42:00 -08:00
Chih-hung Hsieh
a7348efe27 Merge "Allow warnings in modules/camera/3_4." am: d8bffba62a am: dd67309182
am: 38a4fbe55b

Change-Id: If914c66f7c5be51db275cc73f2deb6bb0d19f594
2017-12-08 04:51:30 +00:00
Chih-Hung Hsieh
37ee37170d Allow warnings in modules/camera/3_4.
* This directory still has many warnings to fix.

Bug: 66996870
Test: normal build
Exempt-From-Owner-Approval: quick fix for broken build
Change-Id: I7f3cef3016ba16cb7ddbe6721cf74c71c1cbf1a2
2017-12-07 03:14:09 +00:00
Chih-Hung Hsieh
26ab80dcaa Merge "Use -Werror in hardware/libhardware/modules" am: 298fc4f6f5 am: 66f312b91c
am: 81a536751c

Change-Id: I78eb43d3b34086a03d3e24c7b2ce4b5b2ea1d393
2017-12-06 18:54:17 +00:00
Chih-Hung Hsieh
1f601b1d7d Use -Werror in hardware/libhardware/modules
* Remove unused local variables.
* Remove or comment out unused static functions.
* Fix trivial bugs found by unused value warnings.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I99389b883c89551850180d25241a35a40bb77b26
2017-12-01 10:37:19 -08:00
Jaesung Chung
6e8afead53 Override HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED during setuping streams
This CL makes the hack(ag/3176281) in frameworks/av not needed no longer.

Bug: 69321320
Test: After reverting the hack in av, the camera sample app works.
Exempt-From-Owner-Approval: HAL is owned by Things team.
Change-Id: I510531bed401fe4fa6071fc151a1f75307a5decb
2017-11-16 02:30:38 +00:00
Jaesung Chung
424744cc4d Use RGB24 format instead of BGR32
BGR32 mode is in RPi3's camera has a RB color swapping issue. This CL
makes to use stable RGB24 mode instead to avoid the problem without
causing any quality regression.

Bug: 69075512
Test: RB color swapping problem is gone on preview, recording and stil.
Exempt-From-Owner-Approval: HAL is owned by Things team.
Change-Id: I109363c0f68cec45f92e739a978f554e70032151
2017-11-14 08:00:16 +00:00
TreeHugger Robot
0811139dd8 Merge "Close acquire fence fd after camera capture" 2017-11-13 08:23:09 +00:00
Eric Jeong
eadafff6ae Close acquire fence fd after camera capture
Camera capture should close acquire fence. If not, fd remains unused,
which consumes all available fd resources for a process (usually 1024).

Bug: 64214375
Test: Running camera preview of camera sample app for a long time
      should not break preview image.
Exempt-From-Owner-Approval: This is a cherry-pick CL from oc-iot-dev.      
Change-Id: I91d6d3a7b7a95ed5b33c7c73bc85d42f69f4c856
(cherry picked from commit da3c52413a7499a3cd91246b0634f839315ed7b7)
2017-11-13 06:52:28 +00:00
Jaesung Chung
1fc9b614b8 Fix lock mechanism in v4l2 camera HAL
Both in_flight_lock_ lock in v4l2_camera.cpp and buffer_queue_lock_ in
v4l2_wrapper.cpp have problems that guards the buffer indices and in
flight buffer vector incorrectly. Those problem leads to mismatching in
terms of buffer size between the HAL and Camera3Device and eventually
the Camera3Device will stop to wait for buffers that HAL will not post
in the future.

Bug: 69076261
Test: Camera samples app doesn't stuck with FB impl.
Exempt-From-Owner-Approval: got +2 from the HAL maintainer.
Change-Id: I3d0a4361d46571fd144a5eb8bc160296a31d6358
2017-11-13 02:25:48 +00:00
Dan Albert
81895aad17 Add missing includes.
Change-Id: Id6a97bfdb28f155f691891c746cbc1008e6ce083
Exempt-From-Owner-Approval: trivial cleanup
Test: mma
Bug: None
2017-10-12 13:31:52 -07:00
Mark Salyzyn
8774152335 resolve merge conflicts of 7c451a93 to oc-dev-plus-aosp
am: 1ae7379baa

Change-Id: Id715cb96a71fc9e48e14ff2e6f9e4883402aa6f6
2017-04-12 16:28:32 +00:00
Mark Salyzyn
1ae7379baa resolve merge conflicts of 7c451a93 to oc-dev-plus-aosp
Test: I solemnly swear I tested this conflict resolution.
Bug: 34250038
Change-Id: I4196a6d5a1365106643ac6c1548fd86faffead6f
2017-04-12 09:11:38 -07:00
Mark Salyzyn
d88dfe8607 libhardware: deprecate cutils/log.h
Replace cutils/log.h with log/log.h. Sort headers. Minimize conflicts.
Add missing required headers.

Test: compile
Bug: 34250038
Change-Id: I5c0f231cbfed90b73e0538c9d32ad3226c7cc5e4
2017-04-11 10:50:06 -07:00
Ari Hausman-Cohen
7d19579b78 Merge V4L2 camera HAL from nyc-iot-dev into master
Bug: 35856819
Test: Build on master
Change-Id: Ie5bd08bb82cc810964ff9d9ed046a7bc33d16187
2017-03-27 15:19:04 -07:00