diff --git a/Dockerfile.openpilot b/Dockerfile.openpilot
index 2428249fae61ee..de602f3bca96c7 100644
--- a/Dockerfile.openpilot
+++ b/Dockerfile.openpilot
@@ -1,7 +1,26 @@
FROM ubuntu:16.04
ENV PYTHONUNBUFFERED 1
-RUN apt-get update && apt-get install -y build-essential clang vim screen wget bzip2 git libglib2.0-0 python-pip capnproto libcapnp-dev libzmq5-dev libffi-dev libusb-1.0-0
+RUN apt-get update && apt-get install -y \
+ build-essential \
+ clang \
+ vim \
+ screen \
+ wget \
+ bzip2 \
+ git \
+ libglib2.0-0 \
+ python-pip \
+ capnproto \
+ libcapnp-dev \
+ libzmq5-dev \
+ libffi-dev \
+ libusb-1.0-0 \
+ libssl-dev \
+ ocl-icd-libopencl1 \
+ ocl-icd-opencl-dev \
+ opencl-headers
+
RUN pip install numpy==1.11.2 scipy==0.18.1 matplotlib==2.1.2
COPY requirements_openpilot.txt /tmp/
diff --git a/README.md b/README.md
index 2aaeea023819a5..6cc1b67ce708c6 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,7 @@ Supported Cars
| Chevrolet3| Malibu 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7|
| Chevrolet3| Volt 2017-18 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7|
| Cadillac3 | ATS 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7|
+| Chrysler | Pacifica Hybrid 2017 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | Custom8|
| GMC3 | Acadia Denali 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7|
| Holden3 | Astra 2017 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | Custom7|
| Honda | Accord 2018 | All | Yes | Stock | 0mph | 3mph | Bosch |
@@ -100,35 +101,32 @@ Supported Cars
3[GM installation guide](https://zoneos.com/volt/).
4It needs an extra 120Ohm resistor ([pic1](https://i.imgur.com/CmdKtTP.jpg), [pic2](https://i.imgur.com/s2etUo6.jpg)) on bus 3 and giraffe switches set to 01X1 (11X1 for stock LKAS), where X depends on if you have the [comma power](https://comma.ai/shop/products/power/).
528mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
-6Open sourced [Hyundai Giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai) is designed ofor the 2019 Sante Fe; pinout may differ for other Hyundais.
-7Community built Giraffe, find more information here, [GM Giraffe](https://zoneos.com/shop/).
+6Open sourced [Hyundai Giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai) is designed for the 2019 Sante Fe; pinout may differ for other Hyundais.
+7Community built Giraffe, find more information [here](https://zoneos.com/shop/).
+8Community built Giraffe, find more information [here](https://github.com/adhintz/openpilot/wiki). Comma official Giraffe coming soon.
Community Maintained Cars
------
-| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below | Giraffe |
-| ------- | ---------------------- | -------------------- | ------- | ------------ | -------------- | -------------- | ------------------|
-| Honda | Fit 2018 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Inverted Nidec |
-| Tesla | Model S 2012 | All | Yes | Not yet | Not applicable | 0mph | Custom8|
-| Tesla | Model S 2013 | All | Yes | Not yet | Not applicable | 0mph | Custom8|
+| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below | Giraffe |
+| ---------------------| -------------------------| ---------------------| --------| ---------------| -----------------| ---------------|-------------------|
+| Honda | Fit 2018 | Honda Sensing | Yes | Yes | 25mph1| 12mph | Inverted Nidec |
+| Tesla | Model S 2012 | All | Yes | Not yet | Not applicable | 0mph | Custom9|
+| Tesla | Model S 2013 | All | Yes | Not yet | Not applicable | 0mph | Custom9|
[[Honda Fit Pull Request]](https://github.com/commaai/openpilot/pull/266).
[[Tesla Model S Pull Request]](https://github.com/commaai/openpilot/pull/246)
-8Community built Giraffe, find more information here [Community Tesla Giraffe](https://github.com/jeankalud/neo/tree/tesla_giraffe/giraffe/tesla)
+9Community built Giraffe, find more information here [Community Tesla Giraffe](https://github.com/jeankalud/neo/tree/tesla_giraffe/giraffe/tesla)
Community Maintained Cars are not confirmed by comma.ai to meet our [safety model](https://github.com/commaai/openpilot/blob/devel/SAFETY.md). Be extra cautious using them.
In Progress Cars
------
-- All TSS-P Toyota with Steering Assist.
- - 'Full Speed Range Dynamic Radar Cruise Control' is required to enable stop-and-go. Only the Prius, Camry and C-HR have this option.
- - Even though the Tundra, Sequoia and the Land Cruiser have TSS-P, they don't have Steering Assist and are not supported.
+- All TSS-P Toyota with Steering Assist and LSS-P Lexus with Steering Assist or Lane Keep Assist.
- Only remaining Toyota cars with no port yet are the Avalon and the Sienna.
-- All LSS-P Lexus with Steering Assist or Lane Keep Assist.
- - 'All-Speed Range Dynamic Radar Cruise Control' is required to enable stop-and-go. Only the GS, GSH, F, RX, RXH, LX, NX, NXH, LC, LCH, LS, LSH have this option.
- - Even though the LX have TSS-P, it does not have Steering Assist and is not supported.
- All Hyundai with SmartSense.
- All Kia with SCC and LKAS.
+- All Chrysler, Jeep, Fiat with Adaprive Cruise Control and LaneSense.
How can I add support for my car?
------
@@ -137,7 +135,7 @@ If your car has adaptive cruise control and lane keep assist, you are in luck. U
We've written guides for [Brand](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84) and [Model](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) ports. These guides might help you after you have the basics figured out.
-- BMW, Audi, Volvo, and Mercedes all use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) and are unlikely to be supported any time soon.
+- BMW, Audi, Volvo, and Mercedes all use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) and can be supported after [FlexRay support](https://github.com/commaai/openpilot/pull/463) is merged.
- We put time into a Ford port, but the steering has a 10 second cutout limitation that makes it unusable.
- The 2016-2017 Honda Accord uses a custom signaling protocol for steering that's unlikely to ever be upstreamed.
@@ -187,23 +185,21 @@ By using it, you agree to [our privacy policy](https://community.comma.ai/privac
Testing on PC
------
-There is rudimentary infrastructure to run a basic simulation and generate a report of openpilot's behavior in different scenarios.
+Check out [openpilot-tools](https://github.com/commaai/openpilot-tools): lots of tools you can use to replay driving data, test and develop openpilot from your pc.
+
+Also, within openpilot there is a rudimentary infrastructure to run a basic simulation and generate a report of openpilot's behavior in different longitudinal control scenarios.
```bash
# Requires working docker
./run_docker_tests.sh
```
-The resulting plots are displayed in `selfdrive/test/tests/plant/out/longitudinal/index.html`
-
-More extensive testing infrastructure and simulation environments are coming soon.
-
-
Contributing
------
-We welcome both pull requests and issues on
-[github](http://github.com/commaai/openpilot). Bug fixes and new car ports encouraged.
+We welcome both pull requests and issues on [github](http://github.com/commaai/openpilot). Bug fixes and new car ports encouraged.
+
+We also have a [bounty program](https://comma.ai/bounties.html).
Want to get paid to work on openpilot? [comma.ai is hiring](https://comma.ai/jobs/)
diff --git a/RELEASES.md b/RELEASES.md
index 216feb83cfcf61..482f2009186302 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,3 +1,13 @@
+Version 0.5.8 (2019-01-17)
+========================
+ * Open sourced visiond
+ * Auto-slowdown for upcoming turns
+ * Chrysler/Jeep/Fiat support thanks to adhintz!
+ * Honda Civic 2019 support thanks to csouers!
+ * Improved use of car display in Toyota thanks to arne182!
+ * No data upload when connected to Android or iOS hotspots and "Enable Upload Over Cellular" setting is off
+ * EON stops charging when 12V battery drops below 11.8V
+
Version 0.5.7 (2018-12-06)
========================
* Speed limit from OpenStreetMap added to UI
diff --git a/apk/ai.comma.plus.frame.apk b/apk/ai.comma.plus.frame.apk
index 75a03888c153b7..461b2c03602896 100644
--- a/apk/ai.comma.plus.frame.apk
+++ b/apk/ai.comma.plus.frame.apk
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:b4ebea7b71bee8e519ac6135fab68178fa81cc7dcae1eb02ff65f55b45f9c980
-size 2586402
+oid sha256:b8851680f5bd393fa23868a7d4f3911083280e9bc7ae4a5dbe251ba8dfa21a11
+size 2586396
diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk
index c328b808a4bede..21dad082e24e7b 100644
--- a/apk/ai.comma.plus.offroad.apk
+++ b/apk/ai.comma.plus.offroad.apk
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:fd1b73de8429efcab05daa82f7f1f43bb508154c5c1d2e3a5822095071775ade
-size 18359184
+oid sha256:9dd7d3fa39ebf435b467c4bc8ced9e51c440f1cc7c09089c65fdcd3d1a92fa3d
+size 18387934
diff --git a/cereal/car.capnp b/cereal/car.capnp
index bf982f8aba0da6..fbcbb1065137ee 100644
--- a/cereal/car.capnp
+++ b/cereal/car.capnp
@@ -244,6 +244,8 @@ struct CarControl {
leadVisible @3: Bool;
visualAlert @4: VisualAlert;
audibleAlert @5: AudibleAlert;
+ rightLaneVisible @6: Bool;
+ leftLaneVisible @7: Bool;
enum VisualAlert {
# these are the choices from the Honda
diff --git a/cereal/log.capnp b/cereal/log.capnp
index e643728e0031ec..0ebf6a730094e4 100644
--- a/cereal/log.capnp
+++ b/cereal/log.capnp
@@ -187,10 +187,10 @@ struct SensorEventData {
iOS @1;
fiber @2;
velodyne @3; # Velodyne IMU
- # c3 sensors below
- bno055 @4;
- lsm6ds3 @5;
- bmp280 @6;
+ bno055 @4; # Bosch accelerometer
+ lsm6ds3 @5; # accelerometer (c2)
+ bmp280 @6; # barometer (c2)
+ mmc3416x @7; # magnetometer (c2)
}
}
@@ -399,6 +399,8 @@ struct Live100Data {
curvature @37 :Float32; # path curvature from vehicle model
hudLeadDEPRECATED @14 :Int32;
cumLagMs @15 :Float32;
+ startMonoTime @48 :UInt64;
+ mapValid @49 :Bool;
enabled @19 :Bool;
active @36 :Bool;
@@ -420,6 +422,10 @@ struct Live100Data {
engageable @41 :Bool; # can OP be engaged?
driverMonitoringOn @43 :Bool;
+ # maps
+ vCurvature @46 :Float32;
+ decelForTurn @47 :Bool;
+
enum ControlState {
disabled @0;
preEnabled @1;
@@ -556,6 +562,8 @@ struct Plan {
aTarget @18 :Float32;
jerkFactor @6 :Float32;
hasLead @7 :Bool;
+ hasLeftLane @23 :Bool;
+ hasRightLane @24 :Bool;
fcw @8 :Bool;
longitudinalPlanSource @15 :LongitudinalPlanSource;
@@ -567,6 +575,7 @@ struct Plan {
# maps
vCurvature @21 :Float32;
decelForTurn @22 :Bool;
+ mapValid @25 :Bool;
struct GpsTrajectory {
x @0 :List(Float32);
@@ -1584,8 +1593,15 @@ struct LiveMapData {
roadCurvatureX @8 :List(Float32);
roadCurvature @9 :List(Float32);
distToTurn @10 :Float32;
+ mapValid @11 :Bool;
}
+struct CameraOdometry {
+ trans @0 :List(Float32); # m/s in device frame
+ rot @1 :List(Float32); # rad/s in device frame
+ transStd @2 :List(Float32); # std m/s in device frame
+ rotStd @3 :List(Float32); # std rad/s in device frame
+}
struct Event {
# in nanoseconds?
@@ -1654,5 +1670,6 @@ struct Event {
boot @60 :Boot;
liveParameters @61 :LiveParametersData;
liveMapData @62 :LiveMapData;
+ cameraOdometry @63 :CameraOdometry;
}
}
diff --git a/common/transformations/camera.py b/common/transformations/camera.py
index e7472f53302f9e..6cf517cf50efb7 100644
--- a/common/transformations/camera.py
+++ b/common/transformations/camera.py
@@ -1,5 +1,6 @@
import numpy as np
import common.transformations.orientation as orient
+import cv2
FULL_FRAME_SIZE = (1164, 874)
W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1]
@@ -62,31 +63,35 @@ def roll_from_ke(m):
return np.arctan2(-(m[1, 0] - m[1, 1] * m[2, 0] / m[2, 1]),
-(m[0, 0] - m[0, 1] * m[2, 0] / m[2, 1]))
-def normalize(img_pts):
+
+def normalize(img_pts, intrinsics=eon_intrinsics):
# normalizes image coordinates
# accepts single pt or array of pts
+ intrinsics_inv = np.linalg.inv(intrinsics)
img_pts = np.array(img_pts)
input_shape = img_pts.shape
img_pts = np.atleast_2d(img_pts)
img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0],1))))
- img_pts_normalized = eon_intrinsics_inv.dot(img_pts.T).T
+ img_pts_normalized = intrinsics_inv.dot(img_pts.T).T
img_pts_normalized[(img_pts < 0).any(axis=1)] = np.nan
return img_pts_normalized[:,:2].reshape(input_shape)
-def denormalize(img_pts):
+
+def denormalize(img_pts, intrinsics=eon_intrinsics):
# denormalizes image coordinates
# accepts single pt or array of pts
img_pts = np.array(img_pts)
input_shape = img_pts.shape
img_pts = np.atleast_2d(img_pts)
img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0],1))))
- img_pts_denormalized = eon_intrinsics.dot(img_pts.T).T
+ img_pts_denormalized = intrinsics.dot(img_pts.T).T
img_pts_denormalized[img_pts_denormalized[:,0] > W] = np.nan
img_pts_denormalized[img_pts_denormalized[:,0] < 0] = np.nan
img_pts_denormalized[img_pts_denormalized[:,1] > H] = np.nan
img_pts_denormalized[img_pts_denormalized[:,1] < 0] = np.nan
return img_pts_denormalized[:,:2].reshape(input_shape)
+
def device_from_ecef(pos_ecef, orientation_ecef, pt_ecef):
# device from ecef frame
# device frame is x -> forward, y-> right, z -> down
@@ -99,6 +104,7 @@ def device_from_ecef(pos_ecef, orientation_ecef, pt_ecef):
pt_device = np.einsum('jk,ik->ij', device_from_ecef_rot, pt_ecef_rel)
return pt_device.reshape(input_shape)
+
def img_from_device(pt_device):
# img coordinates from pts in device frame
# first transforms to view frame, then to img coords
@@ -113,3 +119,30 @@ def img_from_device(pt_device):
pt_img = pt_view/pt_view[:,2:3]
return pt_img.reshape(input_shape)[:,:2]
+
+def rotate_img(img, eulers, crop=None, intrinsics=eon_intrinsics):
+ size = img.shape[:2]
+ rot = orient.rot_from_euler(eulers)
+ quadrangle = np.array([[0, 0],
+ [size[1]-1, 0],
+ [0, size[0]-1],
+ [size[1]-1, size[0]-1]], dtype=np.float32)
+ quadrangle_norm = np.hstack((normalize(quadrangle, intrinsics=intrinsics), np.ones((4,1))))
+ warped_quadrangle_full = np.einsum('ij, kj->ki', intrinsics.dot(rot), quadrangle_norm)
+ warped_quadrangle = np.column_stack((warped_quadrangle_full[:,0]/warped_quadrangle_full[:,2],
+ warped_quadrangle_full[:,1]/warped_quadrangle_full[:,2])).astype(np.float32)
+ if crop:
+ W_border = (size[1] - crop[0])/2
+ H_border = (size[0] - crop[1])/2
+ outside_crop = (((warped_quadrangle[:,0] < W_border) |
+ (warped_quadrangle[:,0] >= size[1] - W_border)) &
+ ((warped_quadrangle[:,1] < H_border) |
+ (warped_quadrangle[:,1] >= size[0] - H_border)))
+ if not outside_crop.all():
+ raise ValueError("warped image not contained inside crop")
+ else:
+ H_border, W_border = 0, 0
+ M = cv2.getPerspectiveTransform(quadrangle, warped_quadrangle)
+ img_warped = cv2.warpPerspective(img, M, size[::-1])
+ return img_warped[H_border: size[0] - H_border,
+ W_border: size[1] - W_border]
diff --git a/common/transformations/orientation.py b/common/transformations/orientation.py
index 9e4edd456b27d6..33a822ca3fd498 100644
--- a/common/transformations/orientation.py
+++ b/common/transformations/orientation.py
@@ -221,6 +221,8 @@ def ned_euler_from_ecef(ned_ecef_init, ecef_poses):
ecef_poses = array(ecef_poses)
output_shape = ecef_poses.shape
ned_ecef_init = np.atleast_2d(ned_ecef_init)
+ if ned_ecef_init.shape[0] == 1:
+ ned_ecef_init = np.tile(ned_ecef_init[0], (output_shape[0], 1))
ecef_poses = np.atleast_2d(ecef_poses)
ned_poses = np.zeros(ecef_poses.shape)
diff --git a/models/driving_model.dlc b/models/driving_model.dlc
new file mode 100644
index 00000000000000..7d7b35e9554c88
--- /dev/null
+++ b/models/driving_model.dlc
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d1805ad557a93999b787ab1fd66f4bcef7d25226b123bd4f49774340f2e7476c
+size 6354536
diff --git a/models/monitoring_model.dlc b/models/monitoring_model.dlc
new file mode 100644
index 00000000000000..ca9ebeb205c706
--- /dev/null
+++ b/models/monitoring_model.dlc
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:782e58e2fcbcbb39011011aa72c884ab3aa0cef22c434282df17ce5d64f2cba1
+size 428100
diff --git a/phonelibs/boringssl/build.txt b/phonelibs/boringssl/build.txt
new file mode 100644
index 00000000000000..3e160a94d2f5a0
--- /dev/null
+++ b/phonelibs/boringssl/build.txt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:af14d5140665d8ac4aabe25f67d9578ee0b2c7cda3ad32ac3616c3dfa8115592
+size 315
diff --git a/phonelibs/boringssl/include/openssl/aead.h b/phonelibs/boringssl/include/openssl/aead.h
new file mode 100644
index 00000000000000..09c7913f753b2f
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/aead.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f3afba5e6a8f23ac0348d6a233d2a401228ae0f7d9956b970731662f50bdf786
+size 14753
diff --git a/phonelibs/boringssl/include/openssl/aes.h b/phonelibs/boringssl/include/openssl/aes.h
new file mode 100644
index 00000000000000..b040b2c317970c
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/aes.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e29da7d8db052a32ad2851f2f5b8e26881448f3c136049d933faef1e923b519b
+size 6692
diff --git a/phonelibs/boringssl/include/openssl/asn1.h b/phonelibs/boringssl/include/openssl/asn1.h
new file mode 100644
index 00000000000000..8254b5be5244d5
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/asn1.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:29e1abbf53777da99279be31fce3194f97a99f769ddf5aa04a18e1f2f8f4ad84
+size 49368
diff --git a/phonelibs/boringssl/include/openssl/asn1_mac.h b/phonelibs/boringssl/include/openssl/asn1_mac.h
new file mode 100644
index 00000000000000..3553e035deda4e
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/asn1_mac.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:fde813a06dc83d87d8518afb3ab4f63db05822720e65ada7dde213b741f42f71
+size 3430
diff --git a/phonelibs/boringssl/include/openssl/asn1t.h b/phonelibs/boringssl/include/openssl/asn1t.h
new file mode 100644
index 00000000000000..e3fe800bc4df4e
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/asn1t.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c274ec51b1c3ac67957eb5b46565471c504c9ef9bf231ae0019edb71f7817125
+size 28982
diff --git a/phonelibs/boringssl/include/openssl/base.h b/phonelibs/boringssl/include/openssl/base.h
new file mode 100644
index 00000000000000..0d11bd859e98b9
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/base.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cc2b7b83744ab8d032e60cd98a52f39246f1621a293ee39de00ba01cefaa8706
+size 8065
diff --git a/phonelibs/boringssl/include/openssl/base64.h b/phonelibs/boringssl/include/openssl/base64.h
new file mode 100644
index 00000000000000..22c517c27cd69c
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/base64.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:57d67405be21bf43ee16a18baaa1f1c94a07ce35067f08f85ef14943b76662d4
+size 8094
diff --git a/phonelibs/boringssl/include/openssl/bio.h b/phonelibs/boringssl/include/openssl/bio.h
new file mode 100644
index 00000000000000..3dc8672983ad60
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/bio.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:610c9628b9c05c9d9c69281854a3976f455ded3bf59645e8772f7be75fbc807d
+size 38244
diff --git a/phonelibs/boringssl/include/openssl/blowfish.h b/phonelibs/boringssl/include/openssl/blowfish.h
new file mode 100644
index 00000000000000..5d07abd4c28420
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/blowfish.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:86a2f8f2a86f700a9af822bf4f6b267feaae780c6c51386f0d10e21184d542e7
+size 4092
diff --git a/phonelibs/boringssl/include/openssl/bn.h b/phonelibs/boringssl/include/openssl/bn.h
new file mode 100644
index 00000000000000..dd5ed2f33b68ea
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/bn.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6b95173302407baff9321848ac81ace0fb0a8864e090c48ab90e3643736001c6
+size 39340
diff --git a/phonelibs/boringssl/include/openssl/buf.h b/phonelibs/boringssl/include/openssl/buf.h
new file mode 100644
index 00000000000000..4bdbf36d444875
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/buf.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d652b74ae7c88c064d5f16d303240ada3465af58db7db266ab09d6ea1574900d
+size 5401
diff --git a/phonelibs/boringssl/include/openssl/buffer.h b/phonelibs/boringssl/include/openssl/buffer.h
new file mode 100644
index 00000000000000..1333103f96c968
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/buffer.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9d3ea6b2ef3ad19dd0394b0e8f8cab43544559cc9563dd5c5eadf1831024061a
+size 891
diff --git a/phonelibs/boringssl/include/openssl/bytestring.h b/phonelibs/boringssl/include/openssl/bytestring.h
new file mode 100644
index 00000000000000..cd7e6327d54418
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/bytestring.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5aabc0b54e954acff397c3fe646b9973777709b668c784f2bec3b31885033f07
+size 15119
diff --git a/phonelibs/boringssl/include/openssl/cast.h b/phonelibs/boringssl/include/openssl/cast.h
new file mode 100644
index 00000000000000..a82f5676256f15
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/cast.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bee09d5686a789ca7e87df90d736a93ff46305d895b5fc6af7b225bd25076f32
+size 4395
diff --git a/phonelibs/boringssl/include/openssl/chacha.h b/phonelibs/boringssl/include/openssl/chacha.h
new file mode 100644
index 00000000000000..d91498f59ce3e7
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/chacha.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2c9ba2e8cd8db0b7f4f0f9cf23008106977f272a074029b616c1c558a42db591
+size 1379
diff --git a/phonelibs/boringssl/include/openssl/cipher.h b/phonelibs/boringssl/include/openssl/cipher.h
new file mode 100644
index 00000000000000..f5e01fdf850d68
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/cipher.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cb624522cf6de5951a69920a93d91fcb917b35b762c3215d1c7702c9f9c50e9e
+size 25412
diff --git a/phonelibs/boringssl/include/openssl/cmac.h b/phonelibs/boringssl/include/openssl/cmac.h
new file mode 100644
index 00000000000000..135641d029d2f4
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/cmac.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a7df1fc289bc0abf9ecde865034132f00928de2525f4a0c07b6eee2d72ffa2af
+size 2868
diff --git a/phonelibs/boringssl/include/openssl/conf.h b/phonelibs/boringssl/include/openssl/conf.h
new file mode 100644
index 00000000000000..2006a80ca16748
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/conf.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f0c28ccc0b9229242919d0d38ef5322e73f0b668c46cb2dd75df439d7fabca6f
+size 6086
diff --git a/phonelibs/boringssl/include/openssl/cpu.h b/phonelibs/boringssl/include/openssl/cpu.h
new file mode 100644
index 00000000000000..1686636995cfc3
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/cpu.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:452f9d5c46bb295d5f57294b13fc4ea951d487b65eb2065cd199617b79648c41
+size 5521
diff --git a/phonelibs/boringssl/include/openssl/crypto.h b/phonelibs/boringssl/include/openssl/crypto.h
new file mode 100644
index 00000000000000..eafe696432f0be
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/crypto.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:020b2897d2f2a11c577f533a1531d6b99b6d72054b06125e84ba9499c2bee079
+size 1986
diff --git a/phonelibs/boringssl/include/openssl/des.h b/phonelibs/boringssl/include/openssl/des.h
new file mode 100644
index 00000000000000..c006cc16851786
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/des.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:aa693fc45f88b4278ecbe726c191dc0b34ef80e65737baee1a978523fc67181d
+size 6740
diff --git a/phonelibs/boringssl/include/openssl/dh.h b/phonelibs/boringssl/include/openssl/dh.h
new file mode 100644
index 00000000000000..be9a1c9b715f2f
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/dh.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:53166f08c6bcaf9b9f235de16a96099e392bf2edcc86eefb0d070d6cb87a2b6f
+size 10607
diff --git a/phonelibs/boringssl/include/openssl/digest.h b/phonelibs/boringssl/include/openssl/digest.h
new file mode 100644
index 00000000000000..fba83b2be33bb9
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/digest.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5093b61ded8f0e3b2075f0eda4ce3cfe77280a8674632f3288b52e2f47a36d74
+size 11310
diff --git a/phonelibs/boringssl/include/openssl/dsa.h b/phonelibs/boringssl/include/openssl/dsa.h
new file mode 100644
index 00000000000000..55f94a319b5e71
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/dsa.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b1b97ff90f0f902355420b8f37aa90fef8a24f43941a14da07886f4ae5e2f0d8
+size 16539
diff --git a/phonelibs/boringssl/include/openssl/dtls1.h b/phonelibs/boringssl/include/openssl/dtls1.h
new file mode 100644
index 00000000000000..4ba29bf7d4fc26
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/dtls1.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ff5aa6b5001ee98886d9b5fe1de41d2ab4ce6202c1c4fe4de977a3db002f2b2b
+size 873
diff --git a/phonelibs/boringssl/include/openssl/ec.h b/phonelibs/boringssl/include/openssl/ec.h
new file mode 100644
index 00000000000000..49b74ef48424a0
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ec.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4b054c48d63f248d67305d55cdf6c80bd2d60b463def591397cdac3474e1e050
+size 19002
diff --git a/phonelibs/boringssl/include/openssl/ec_key.h b/phonelibs/boringssl/include/openssl/ec_key.h
new file mode 100644
index 00000000000000..5ad3a35f1ab45f
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ec_key.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac42130236cc26b99c4ff7488894498f6be1c1454ca52616b640f907d96d2d30
+size 12412
diff --git a/phonelibs/boringssl/include/openssl/ecdh.h b/phonelibs/boringssl/include/openssl/ecdh.h
new file mode 100644
index 00000000000000..a2edb99304a2d0
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ecdh.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1f97b9f76de188f3e17a62b46374beb5d5105cd3053b0175c0ef7affefb9a2f1
+size 4311
diff --git a/phonelibs/boringssl/include/openssl/ecdsa.h b/phonelibs/boringssl/include/openssl/ecdsa.h
new file mode 100644
index 00000000000000..d41d26f5a5af5d
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ecdsa.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7976ea583d1ffbe9468ae0876f26adce5666ac436a99cf05a4243d06f677518a
+size 7950
diff --git a/phonelibs/boringssl/include/openssl/engine.h b/phonelibs/boringssl/include/openssl/engine.h
new file mode 100644
index 00000000000000..2ef9006c0a91de
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/engine.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8006301899cbda2d7471e8130729e2fa2568552e3af87f64fbb7ba0d8c1d9077
+size 4111
diff --git a/phonelibs/boringssl/include/openssl/err.h b/phonelibs/boringssl/include/openssl/err.h
new file mode 100644
index 00000000000000..197a9d21b24cdd
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/err.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7ddf159297c47a48c817b5ae39748848b266a7da9f31910465be6a7a593a2151
+size 20995
diff --git a/phonelibs/boringssl/include/openssl/evp.h b/phonelibs/boringssl/include/openssl/evp.h
new file mode 100644
index 00000000000000..7fe22d21235686
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/evp.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ef7666624db4e1e942816550733efc52fe34bc146c5e7dc52b1c822cbe510773
+size 36956
diff --git a/phonelibs/boringssl/include/openssl/ex_data.h b/phonelibs/boringssl/include/openssl/ex_data.h
new file mode 100644
index 00000000000000..210c205132f977
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ex_data.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:53c40f01e68e2584eda77376268d4e6b8fde6dd77a4436a3311b80f0150eb5eb
+size 9878
diff --git a/phonelibs/boringssl/include/openssl/hkdf.h b/phonelibs/boringssl/include/openssl/hkdf.h
new file mode 100644
index 00000000000000..df542602f61ccd
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/hkdf.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c9b098d59b8af8a216545e2fb4362493c78d109e7b9439b2f6124f0a960dd840
+size 1704
diff --git a/phonelibs/boringssl/include/openssl/hmac.h b/phonelibs/boringssl/include/openssl/hmac.h
new file mode 100644
index 00000000000000..06d55487f78548
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/hmac.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b8c1ed64bf18f0c5c2c4f33d4841a8f7db58c28978645df2f0e5647b450ee04b
+size 6951
diff --git a/phonelibs/boringssl/include/openssl/lhash.h b/phonelibs/boringssl/include/openssl/lhash.h
new file mode 100644
index 00000000000000..eab6b778facb22
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/lhash.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1318518f9329e2c10b6953b569077c59d6cd190812fee062d93c8c28064ce988
+size 8043
diff --git a/phonelibs/boringssl/include/openssl/lhash_macros.h b/phonelibs/boringssl/include/openssl/lhash_macros.h
new file mode 100644
index 00000000000000..f810b32f4f0e1b
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/lhash_macros.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1ab6b74da173650c02bef0a0179686988b82005236345cf3c34619d6b08c8798
+size 6472
diff --git a/phonelibs/boringssl/include/openssl/md4.h b/phonelibs/boringssl/include/openssl/md4.h
new file mode 100644
index 00000000000000..e2e50ac2c11d8a
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/md4.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5314f1c95a423d9691f6370b6e9ef8d9a0e1e303bf33ec273a3efb4e0f302124
+size 4350
diff --git a/phonelibs/boringssl/include/openssl/md5.h b/phonelibs/boringssl/include/openssl/md5.h
new file mode 100644
index 00000000000000..6474da403c0038
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/md5.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8f6fce70bba043fd975d4d2bd562e58f6e0d3e40b6af8aafb1db6ca6083e23f1
+size 4582
diff --git a/phonelibs/boringssl/include/openssl/mem.h b/phonelibs/boringssl/include/openssl/mem.h
new file mode 100644
index 00000000000000..1e1cdecbfd9930
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/mem.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a3673eb45d1414c06aeed6da8694015585174928dbc64ba5b1c7414393c0563c
+size 6187
diff --git a/phonelibs/boringssl/include/openssl/modes.h b/phonelibs/boringssl/include/openssl/modes.h
new file mode 100644
index 00000000000000..8387b1b1037714
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/modes.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0b10a8b796478cbf580f4f73b9cbbb99d2dcf0cd37c78ff3917296dd509897e0
+size 10661
diff --git a/phonelibs/boringssl/include/openssl/obj.h b/phonelibs/boringssl/include/openssl/obj.h
new file mode 100644
index 00000000000000..45ffd3dcb59b33
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/obj.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:72c9b4c549756f34eda8153aee5e3ce121389c374cc08806c4bfff3a23e8eeb8
+size 9092
diff --git a/phonelibs/boringssl/include/openssl/obj_mac.h b/phonelibs/boringssl/include/openssl/obj_mac.h
new file mode 100644
index 00000000000000..89b8262d4c1e76
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/obj_mac.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1eca11c60eb1af36afd607e1ba11bdee0c65f882cb870bf4cabae4e0123ba77d
+size 140746
diff --git a/phonelibs/boringssl/include/openssl/objects.h b/phonelibs/boringssl/include/openssl/objects.h
new file mode 100644
index 00000000000000..0b2738f318ad17
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/objects.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e0f9a293ef22ebe20bde25acd4bc008e0ce0f02cfab0de02a23057da6bb51b95
+size 891
diff --git a/phonelibs/boringssl/include/openssl/opensslfeatures.h b/phonelibs/boringssl/include/openssl/opensslfeatures.h
new file mode 100644
index 00000000000000..f54666e9be1302
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/opensslfeatures.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cc08fcb2cc42213bc6495dbd43ca105ef299e7f360ce25cd8d2e8a638e13ca48
+size 1938
diff --git a/phonelibs/boringssl/include/openssl/opensslv.h b/phonelibs/boringssl/include/openssl/opensslv.h
new file mode 100644
index 00000000000000..f9945fae4e518d
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/opensslv.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8b6129b2dc8d28ab72f4a9d632cb36e66b3567673d913e1d3388189bc8125081
+size 894
diff --git a/phonelibs/boringssl/include/openssl/ossl_typ.h b/phonelibs/boringssl/include/openssl/ossl_typ.h
new file mode 100644
index 00000000000000..48c3b462be8733
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ossl_typ.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:178fbd08f198d1735f253aeeee355279f91e416d969e78b449f9f9d3fc393c97
+size 892
diff --git a/phonelibs/boringssl/include/openssl/pem.h b/phonelibs/boringssl/include/openssl/pem.h
new file mode 100644
index 00000000000000..d51ba80580be21
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/pem.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4778727b06e221b72ac7b9d7a77945b5e7359caef8dfa84b08f58dedc0be3749
+size 21044
diff --git a/phonelibs/boringssl/include/openssl/pkcs12.h b/phonelibs/boringssl/include/openssl/pkcs12.h
new file mode 100644
index 00000000000000..1f749a3e6eb1ba
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/pkcs12.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0432f0dff9abd2b37ffc8f5fc04940cbb588af0e431212d6a695853b0bfb103d
+size 893
diff --git a/phonelibs/boringssl/include/openssl/pkcs7.h b/phonelibs/boringssl/include/openssl/pkcs7.h
new file mode 100644
index 00000000000000..de3df4ace4e9c2
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/pkcs7.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:50e2482b1ff462d766a05369528627f1907e6d9fad815a796093673359340d0a
+size 873
diff --git a/phonelibs/boringssl/include/openssl/pkcs8.h b/phonelibs/boringssl/include/openssl/pkcs8.h
new file mode 100644
index 00000000000000..f281ad042b3990
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/pkcs8.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7eee0e382309128545b3ab5c50545b75a236faea5a8fe2e410bd6811738bc03d
+size 9876
diff --git a/phonelibs/boringssl/include/openssl/poly1305.h b/phonelibs/boringssl/include/openssl/poly1305.h
new file mode 100644
index 00000000000000..9e52a9066ea86c
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/poly1305.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3f72d56ce83eea913e286b5210f7efb8e63cbe7a52e7bc634ed1dbf18108c285
+size 1892
diff --git a/phonelibs/boringssl/include/openssl/pqueue.h b/phonelibs/boringssl/include/openssl/pqueue.h
new file mode 100644
index 00000000000000..43a8c7cf930ec9
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/pqueue.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b5bcd9858e9c0d9db483af60ba11e38d24819d0d4f513c996acd539d6fb98c71
+size 5290
diff --git a/phonelibs/boringssl/include/openssl/rand.h b/phonelibs/boringssl/include/openssl/rand.h
new file mode 100644
index 00000000000000..b06b6eb8402cf2
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/rand.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0ed482ab7d9f9af013779d0a2f1294c7c94929b725a921ad42577999ba53e2c1
+size 1927
diff --git a/phonelibs/boringssl/include/openssl/rc4.h b/phonelibs/boringssl/include/openssl/rc4.h
new file mode 100644
index 00000000000000..b0f969729ab701
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/rc4.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:69cea0a57a964de305fec10db900734fef372b53c4a96c25818883de9aacc85a
+size 3911
diff --git a/phonelibs/boringssl/include/openssl/rsa.h b/phonelibs/boringssl/include/openssl/rsa.h
new file mode 100644
index 00000000000000..b6fb323b9db8dd
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/rsa.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0ba6a885af41615d89e8c834d9b31708013b7ff09dcd115ff80e6da6d82e426f
+size 25483
diff --git a/phonelibs/boringssl/include/openssl/safestack.h b/phonelibs/boringssl/include/openssl/safestack.h
new file mode 100644
index 00000000000000..de3df4ace4e9c2
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/safestack.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:50e2482b1ff462d766a05369528627f1907e6d9fad815a796093673359340d0a
+size 873
diff --git a/phonelibs/boringssl/include/openssl/sha.h b/phonelibs/boringssl/include/openssl/sha.h
new file mode 100644
index 00000000000000..261f8ba0fbc60d
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/sha.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:62652a56077375b66884b9f09223d8d5e12846a10df6f3bb24aae809630a263f
+size 9567
diff --git a/phonelibs/boringssl/include/openssl/srtp.h b/phonelibs/boringssl/include/openssl/srtp.h
new file mode 100644
index 00000000000000..39113eb706fd43
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/srtp.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e65572e7f889b7ddb4fe3589634413954fdf09b6dd9afe934ad75e6c59823461
+size 8066
diff --git a/phonelibs/boringssl/include/openssl/ssl.h b/phonelibs/boringssl/include/openssl/ssl.h
new file mode 100644
index 00000000000000..21b2db1580ff4b
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ssl.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5f53b97c0d81d8365d227bdec2242bc7eef358e867cbe07b7b7d78600133d97d
+size 131788
diff --git a/phonelibs/boringssl/include/openssl/ssl2.h b/phonelibs/boringssl/include/openssl/ssl2.h
new file mode 100644
index 00000000000000..b630e14a6cb027
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ssl2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d3296e68efde561ffbf1a39f011cc3e1c162a6ca73eab4b6a739155f43e38dce
+size 10701
diff --git a/phonelibs/boringssl/include/openssl/ssl23.h b/phonelibs/boringssl/include/openssl/ssl23.h
new file mode 100644
index 00000000000000..9ed20ad2a68506
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ssl23.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a0bdb0fbee6821f6945fd0b9dd931a665e58787383dedd19ff7dd91243c60914
+size 3807
diff --git a/phonelibs/boringssl/include/openssl/ssl3.h b/phonelibs/boringssl/include/openssl/ssl3.h
new file mode 100644
index 00000000000000..0529e4c1271c47
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/ssl3.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c57f7e2b358115861a56a429e275e8f8a1df44a20294e9ece04a01c3d9088cd3
+size 28179
diff --git a/phonelibs/boringssl/include/openssl/stack.h b/phonelibs/boringssl/include/openssl/stack.h
new file mode 100644
index 00000000000000..0fa2a0d5d6934a
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/stack.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:633f5c7f57e5193ca737585140e0688c42c219a2197622b46a8d96aac3284917
+size 11845
diff --git a/phonelibs/boringssl/include/openssl/stack_macros.h b/phonelibs/boringssl/include/openssl/stack_macros.h
new file mode 100644
index 00000000000000..a2629cad96fde4
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/stack_macros.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a344e9b8b75e95527d4b66038b532f01670148109778a1ae32b057f8204450ad
+size 185871
diff --git a/phonelibs/boringssl/include/openssl/thread.h b/phonelibs/boringssl/include/openssl/thread.h
new file mode 100644
index 00000000000000..f346cf807cdf2e
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/thread.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8a6e1cc5fbcd2bdf0795b86118b825670c049a9e3474ab8f8b305c1b853172c6
+size 7254
diff --git a/phonelibs/boringssl/include/openssl/time_support.h b/phonelibs/boringssl/include/openssl/time_support.h
new file mode 100644
index 00000000000000..a20c9637ed48d1
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/time_support.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e38da4c3e99782322a73711e3aa885839f5511f29b74d3097f04f17891f21d7e
+size 3679
diff --git a/phonelibs/boringssl/include/openssl/tls1.h b/phonelibs/boringssl/include/openssl/tls1.h
new file mode 100644
index 00000000000000..8b58f4a8864578
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/tls1.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ab9c6c6f2634fe94860f6887a68bb8ca8a2d159222ad4fa099ddece7405aac96
+size 33483
diff --git a/phonelibs/boringssl/include/openssl/type_check.h b/phonelibs/boringssl/include/openssl/type_check.h
new file mode 100644
index 00000000000000..582d9cec514fe9
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/type_check.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9e7698ce94e780f2533f4b8b9d65e489d5b7e56bea831e152ff942d51eb6275c
+size 4201
diff --git a/phonelibs/boringssl/include/openssl/x509.h b/phonelibs/boringssl/include/openssl/x509.h
new file mode 100644
index 00000000000000..e6ac27343b1738
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/x509.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:79d9f322767dc023526dbc50e898d373ea8919729907cf58960e6f85e3d0efd5
+size 52683
diff --git a/phonelibs/boringssl/include/openssl/x509_vfy.h b/phonelibs/boringssl/include/openssl/x509_vfy.h
new file mode 100644
index 00000000000000..d0ca63e80bba90
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/x509_vfy.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:fec341bcdeeb561b5075079cb67fc1cbd59b8bf23392b168d78867809d8f2dfe
+size 26050
diff --git a/phonelibs/boringssl/include/openssl/x509v3.h b/phonelibs/boringssl/include/openssl/x509v3.h
new file mode 100644
index 00000000000000..00dd358165cda8
--- /dev/null
+++ b/phonelibs/boringssl/include/openssl/x509v3.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7abb5788d3470469c03d4dd927788a705ebe9321b385704aaca48d7b6eb711d4
+size 29723
diff --git a/phonelibs/boringssl/lib/libcrypto_static.a b/phonelibs/boringssl/lib/libcrypto_static.a
new file mode 100644
index 00000000000000..539d93ebcdee9b
--- /dev/null
+++ b/phonelibs/boringssl/lib/libcrypto_static.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a562dec9b1773bd09996932baecf8af311caa5ab39731dfe5790760c22703e41
+size 13068948
diff --git a/phonelibs/boringssl/lib/libssl_static.a b/phonelibs/boringssl/lib/libssl_static.a
new file mode 100644
index 00000000000000..1860a6dcce2e00
--- /dev/null
+++ b/phonelibs/boringssl/lib/libssl_static.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6249b5b707a2c7a1ffa58c7bb404568d47370c44034858c5f75481b8149a8ab4
+size 3444202
diff --git a/phonelibs/curl/build.txt b/phonelibs/curl/build.txt
new file mode 100644
index 00000000000000..18be3486039df5
--- /dev/null
+++ b/phonelibs/curl/build.txt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5e293219e2feabe8e18fd9192a632b19dbefa35fe0bcfcea216c8a0e6ee01ca1
+size 156
diff --git a/phonelibs/curl/include/Makefile.am b/phonelibs/curl/include/Makefile.am
new file mode 100644
index 00000000000000..eee1decba1dd53
--- /dev/null
+++ b/phonelibs/curl/include/Makefile.am
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:718d42bded6f4a0b9f13916eefa564f378ff1dd7c3ecfec21d5c7154ea60d2de
+size 80
diff --git a/phonelibs/curl/include/README b/phonelibs/curl/include/README
new file mode 100644
index 00000000000000..a6649c766bf026
--- /dev/null
+++ b/phonelibs/curl/include/README
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:213e1ddc293e7fb3890c56c372e25186cf8a7cee20a32bce9fafb56ae54efb87
+size 2580
diff --git a/phonelibs/curl/include/curl/.gitignore b/phonelibs/curl/include/curl/.gitignore
new file mode 100644
index 00000000000000..b54bfe0efdbf84
--- /dev/null
+++ b/phonelibs/curl/include/curl/.gitignore
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0f7ad1a4ef40a42919b697d1a81286bb4139752457ba5c6591343cc1802c0d6a
+size 33
diff --git a/phonelibs/curl/include/curl/Makefile.am b/phonelibs/curl/include/curl/Makefile.am
new file mode 100644
index 00000000000000..6fea93269f2149
--- /dev/null
+++ b/phonelibs/curl/include/curl/Makefile.am
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:161deb9830b6098e5841ead05eff635b60b017de3771965ba29f05f7e468d00a
+size 2181
diff --git a/phonelibs/curl/include/curl/curl.h b/phonelibs/curl/include/curl/curl.h
new file mode 100644
index 00000000000000..a7bc65760e2dd9
--- /dev/null
+++ b/phonelibs/curl/include/curl/curl.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5d035a821ee57aac9417f13db0230a54d39bd5fdba9024388b1e0ad5162ed203
+size 89830
diff --git a/phonelibs/curl/include/curl/curlbuild.h b/phonelibs/curl/include/curl/curlbuild.h
new file mode 100644
index 00000000000000..5cda9b33789526
--- /dev/null
+++ b/phonelibs/curl/include/curl/curlbuild.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0ec61cef82ade4a34547d4f13db0a1956447af6fd8138cb66e7a907b66434d07
+size 7228
diff --git a/phonelibs/curl/include/curl/curlbuild.h.cmake b/phonelibs/curl/include/curl/curlbuild.h.cmake
new file mode 100644
index 00000000000000..8e91d7d31b15c5
--- /dev/null
+++ b/phonelibs/curl/include/curl/curlbuild.h.cmake
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:778ecad80da0d8370a3949708747a8f6f9082e1fea96e096be58b8d4a3f3a788
+size 7454
diff --git a/phonelibs/curl/include/curl/curlbuild.h.dist b/phonelibs/curl/include/curl/curlbuild.h.dist
new file mode 100644
index 00000000000000..6a3795361f29a6
--- /dev/null
+++ b/phonelibs/curl/include/curl/curlbuild.h.dist
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:faba30bec7cb8a9eb93131335738ce9b83b21d23c24d591b61b31ef1ee7be15a
+size 22319
diff --git a/phonelibs/curl/include/curl/curlbuild.h.in b/phonelibs/curl/include/curl/curlbuild.h.in
new file mode 100644
index 00000000000000..62d1af23e7425c
--- /dev/null
+++ b/phonelibs/curl/include/curl/curlbuild.h.in
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4838f1fb41250e9220c710d87f65a9ca12d87cacf9cd2b99fae97573c07ae0c8
+size 7069
diff --git a/phonelibs/curl/include/curl/curlrules.h b/phonelibs/curl/include/curl/curlrules.h
new file mode 100644
index 00000000000000..b55dd086f91288
--- /dev/null
+++ b/phonelibs/curl/include/curl/curlrules.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:94e8e9ad8f03c4b3fae2328e47c5f94b05d5e7ece387ac67b3fd50936232a473
+size 8580
diff --git a/phonelibs/curl/include/curl/curlver.h b/phonelibs/curl/include/curl/curlver.h
new file mode 100644
index 00000000000000..b7680ae20d1e64
--- /dev/null
+++ b/phonelibs/curl/include/curl/curlver.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4a3fb823c1effd086b930b11ba5b8e0af37d05ba5adf9f220ece9ffb5682e564
+size 3054
diff --git a/phonelibs/curl/include/curl/easy.h b/phonelibs/curl/include/curl/easy.h
new file mode 100644
index 00000000000000..69966f9d3b1fbd
--- /dev/null
+++ b/phonelibs/curl/include/curl/easy.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2f335fd2209e1e57ca11dba5e73fdc9d8d0f2b0830c75e263b71c61dc5717f7a
+size 3472
diff --git a/phonelibs/curl/include/curl/mprintf.h b/phonelibs/curl/include/curl/mprintf.h
new file mode 100644
index 00000000000000..4bcf5e1a5ac465
--- /dev/null
+++ b/phonelibs/curl/include/curl/mprintf.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:956344b847108430470dd6b74eee5fc041c8542af3f961d728f62fb574c4a7bb
+size 2565
diff --git a/phonelibs/curl/include/curl/multi.h b/phonelibs/curl/include/curl/multi.h
new file mode 100644
index 00000000000000..4c61fee838417c
--- /dev/null
+++ b/phonelibs/curl/include/curl/multi.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e5b4547059fc492ead04161dd5e7734a86e50a2179fbf79a94ed189362bef372
+size 14947
diff --git a/phonelibs/curl/include/curl/stdcheaders.h b/phonelibs/curl/include/curl/stdcheaders.h
new file mode 100644
index 00000000000000..c71817cc7280be
--- /dev/null
+++ b/phonelibs/curl/include/curl/stdcheaders.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:970ae8a1a78f3210cda90c6c9548b80e878e181414540bd862c35a47162456d1
+size 1330
diff --git a/phonelibs/curl/include/curl/typecheck-gcc.h b/phonelibs/curl/include/curl/typecheck-gcc.h
new file mode 100644
index 00000000000000..391c35f67a5688
--- /dev/null
+++ b/phonelibs/curl/include/curl/typecheck-gcc.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:815cd999c78332858bb07c80e65b690a792adccdc3ac64627f5593d9aad7704d
+size 37557
diff --git a/phonelibs/curl/lib/libcurl.a b/phonelibs/curl/lib/libcurl.a
new file mode 100644
index 00000000000000..c934b7f3f825ba
--- /dev/null
+++ b/phonelibs/curl/lib/libcurl.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:790ddb3589bca6c47250a9948f95f1aa8d2eeeca78ff175e580d2f26ac66e858
+size 8702816
diff --git a/phonelibs/json11/json11.cpp b/phonelibs/json11/json11.cpp
new file mode 100644
index 00000000000000..cae58813d13eef
--- /dev/null
+++ b/phonelibs/json11/json11.cpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9fc9fcfbc5edd21d0bd6082b5ff324fba1050e4a0229a7e35124c99002f971b2
+size 24808
diff --git a/phonelibs/json11/json11.hpp b/phonelibs/json11/json11.hpp
new file mode 100644
index 00000000000000..b00e959f972b25
--- /dev/null
+++ b/phonelibs/json11/json11.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2bc666c25fbeac541add5f97a92526360e49ff822ba003567f8ca6a29421bf6d
+size 9212
diff --git a/phonelibs/json11/json11.o b/phonelibs/json11/json11.o
new file mode 100644
index 00000000000000..e38132b585feff
--- /dev/null
+++ b/phonelibs/json11/json11.o
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a6514cc6b5b61b83c14dee636771f7747117d7a9704658762ccb98c73a7ff5fe
+size 142824
diff --git a/phonelibs/libyuv/build.txt b/phonelibs/libyuv/build.txt
new file mode 100644
index 00000000000000..fc28d55d1a9579
--- /dev/null
+++ b/phonelibs/libyuv/build.txt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:42326e0f7b6d01f174c3d9288f1eba208bb65209ec768c61aace0672d9026af0
+size 134
diff --git a/phonelibs/libyuv/include/libyuv.h b/phonelibs/libyuv/include/libyuv.h
new file mode 100644
index 00000000000000..b13dcab50537e4
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7cf28fa31e4de1709131f295bfe370674d6ea9962065312cda612fddb874780e
+size 1013
diff --git a/phonelibs/libyuv/include/libyuv/basic_types.h b/phonelibs/libyuv/include/libyuv/basic_types.h
new file mode 100644
index 00000000000000..31c8b3c2ddd86e
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/basic_types.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3ae14008617f0444c95c37d9574864f6141f662325dcc096b5b9bdcecc3a3647
+size 3304
diff --git a/phonelibs/libyuv/include/libyuv/compare.h b/phonelibs/libyuv/include/libyuv/compare.h
new file mode 100644
index 00000000000000..85effee8f841b9
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/compare.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:01b6454093415b3083b780a96135025ca30ec9b4e99a6033c246a5cebed43cb2
+size 2608
diff --git a/phonelibs/libyuv/include/libyuv/compare_row.h b/phonelibs/libyuv/include/libyuv/compare_row.h
new file mode 100644
index 00000000000000..8165d6d9dbf9d6
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/compare_row.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2618e073b8eada31d8c62ad389ba8b62d019c908a12beafa9d77a1c8b6d973be
+size 2768
diff --git a/phonelibs/libyuv/include/libyuv/convert.h b/phonelibs/libyuv/include/libyuv/convert.h
new file mode 100644
index 00000000000000..b446e579522431
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/convert.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:af443667cd79ca1164e4a73f3d4ebce22db65b8aa7c7672bd020f72ba5bf31bc
+size 9849
diff --git a/phonelibs/libyuv/include/libyuv/convert_argb.h b/phonelibs/libyuv/include/libyuv/convert_argb.h
new file mode 100644
index 00000000000000..e453183f535de9
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/convert_argb.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7c42e4b9e58ba2de9fa155f306438c037e4c87bb0d5cf912890ccd633f6c4ebc
+size 11678
diff --git a/phonelibs/libyuv/include/libyuv/convert_from.h b/phonelibs/libyuv/include/libyuv/convert_from.h
new file mode 100644
index 00000000000000..93f6b74662334d
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/convert_from.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9773a033fcf9cdbf40116135f33d58a31fd05c4fd2670b4174ddf6f0ccdb7a16
+size 6654
diff --git a/phonelibs/libyuv/include/libyuv/convert_from_argb.h b/phonelibs/libyuv/include/libyuv/convert_from_argb.h
new file mode 100644
index 00000000000000..db6a8a1f979823
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/convert_from_argb.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d6690829a0f363d7cf2f014bc0e42a71e92d71ef536789215764d26416688743
+size 6346
diff --git a/phonelibs/libyuv/include/libyuv/cpu_id.h b/phonelibs/libyuv/include/libyuv/cpu_id.h
new file mode 100644
index 00000000000000..62c007b8227963
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/cpu_id.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9beebe4b4322fb7e922592ada701bad75a8af7871a1ead15a9f15cb41b0faed4
+size 2560
diff --git a/phonelibs/libyuv/include/libyuv/macros_msa.h b/phonelibs/libyuv/include/libyuv/macros_msa.h
new file mode 100644
index 00000000000000..00aa3f2dfb8a6d
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/macros_msa.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:be356edd21f49ac741502cb14762a8f3565004aac171da15be25e983eae990c0
+size 3003
diff --git a/phonelibs/libyuv/include/libyuv/mjpeg_decoder.h b/phonelibs/libyuv/include/libyuv/mjpeg_decoder.h
new file mode 100644
index 00000000000000..e8eddaec2990dc
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/mjpeg_decoder.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:729ed2e04661f8aadfd2eceb50f6ee8ec989d0db72100198288f94ad0ccf5218
+size 5870
diff --git a/phonelibs/libyuv/include/libyuv/planar_functions.h b/phonelibs/libyuv/include/libyuv/planar_functions.h
new file mode 100644
index 00000000000000..fbc9a96e4fc67c
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/planar_functions.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e43880fd3644bac9dbd2457a8289e281cc89b982563c67d757321a1b0862ff78
+size 20122
diff --git a/phonelibs/libyuv/include/libyuv/rotate.h b/phonelibs/libyuv/include/libyuv/rotate.h
new file mode 100644
index 00000000000000..220bc5944defd0
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/rotate.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ae0befba954c971335079661f40eeea10c27843b2f36193e96b7ad6c626e8368
+size 3867
diff --git a/phonelibs/libyuv/include/libyuv/rotate_argb.h b/phonelibs/libyuv/include/libyuv/rotate_argb.h
new file mode 100644
index 00000000000000..6c4fe33e2484e6
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/rotate_argb.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4084dba33b07e9d17e3a2e64d47a8d888b8be2949a3e9b29a67d65cb88bc6c8a
+size 951
diff --git a/phonelibs/libyuv/include/libyuv/rotate_row.h b/phonelibs/libyuv/include/libyuv/rotate_row.h
new file mode 100644
index 00000000000000..eb7017f342a2c9
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/rotate_row.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac81de2decbd8a8e170b5b36333375a9afaf49be5dee638f553672c6425ed6e1
+size 5043
diff --git a/phonelibs/libyuv/include/libyuv/row.h b/phonelibs/libyuv/include/libyuv/row.h
new file mode 100644
index 00000000000000..3ef7be783de4f9
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/row.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1ffd6dd9ea7e3e8a9a04f0b9da462c61128940a90d75f4d0c48b750d3afa4e36
+size 94296
diff --git a/phonelibs/libyuv/include/libyuv/scale.h b/phonelibs/libyuv/include/libyuv/scale.h
new file mode 100644
index 00000000000000..c510e9612ebd1f
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/scale.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e19487734191aa6210f39106f042f2bc9d0cb5fd4a06c7ff45d54cbedda06c27
+size 3676
diff --git a/phonelibs/libyuv/include/libyuv/scale_argb.h b/phonelibs/libyuv/include/libyuv/scale_argb.h
new file mode 100644
index 00000000000000..6392c5cdf73b52
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/scale_argb.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:23ffc516a4ddbd0c772b72a62aecbcaa4ef0a43c8bf18455def8849e7952f8fe
+size 2035
diff --git a/phonelibs/libyuv/include/libyuv/scale_row.h b/phonelibs/libyuv/include/libyuv/scale_row.h
new file mode 100644
index 00000000000000..0fdd3dbafee1b2
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/scale_row.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7efddc8d6594de2c2ae4b2fb21471c8cea947b3c14029ee7e4b632640c66b7f9
+size 25852
diff --git a/phonelibs/libyuv/include/libyuv/version.h b/phonelibs/libyuv/include/libyuv/version.h
new file mode 100644
index 00000000000000..5359fd2674c8ad
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/version.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:259a5675d1e2bb6f62582a436950b53350e9a830b7b9424bb5c6de90b73aec2b
+size 544
diff --git a/phonelibs/libyuv/include/libyuv/video_common.h b/phonelibs/libyuv/include/libyuv/video_common.h
new file mode 100644
index 00000000000000..c7b2841abe68ee
--- /dev/null
+++ b/phonelibs/libyuv/include/libyuv/video_common.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9609ba954cfe314a6d5be78c92d57ddf8bd434493b4876e04efef8606fc4f618
+size 6632
diff --git a/phonelibs/libyuv/lib/libyuv.a b/phonelibs/libyuv/lib/libyuv.a
new file mode 100644
index 00000000000000..4e7d62e488d4f9
--- /dev/null
+++ b/phonelibs/libyuv/lib/libyuv.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:770dac807d5a8ad67e077b41826e375b81a0d50b0c43c5d1fb1cd6ae8a19d6d3
+size 439498
diff --git a/phonelibs/libyuv/mac/lib/libyuv.a b/phonelibs/libyuv/mac/lib/libyuv.a
new file mode 100644
index 00000000000000..c4c6b7969efb90
--- /dev/null
+++ b/phonelibs/libyuv/mac/lib/libyuv.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cd9322e6d95a76ecde062f12627762f5904add8264c5425fa59293270d0ee63b
+size 484992
diff --git a/phonelibs/libyuv/tx2/libyuv.a b/phonelibs/libyuv/tx2/libyuv.a
new file mode 100644
index 00000000000000..87ce9b41fb2f00
--- /dev/null
+++ b/phonelibs/libyuv/tx2/libyuv.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:589237cf678925cd37559a7c6ee9d7b00120d2f9c3fdb9a299f0bac600a8c67b
+size 465698
diff --git a/phonelibs/libyuv/x64/include b/phonelibs/libyuv/x64/include
new file mode 120000
index 00000000000000..f5030fe8899824
--- /dev/null
+++ b/phonelibs/libyuv/x64/include
@@ -0,0 +1 @@
+../include
\ No newline at end of file
diff --git a/phonelibs/libyuv/x64/lib/libyuv.a b/phonelibs/libyuv/x64/lib/libyuv.a
new file mode 100644
index 00000000000000..00f96d56db0cf7
--- /dev/null
+++ b/phonelibs/libyuv/x64/lib/libyuv.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e3bbcce77163b1b920c95579145bac234a795aea26c59a92bc4efcb3bff2415b
+size 499242
diff --git a/phonelibs/snpe/include/DiagLog/IDiagLog.hpp b/phonelibs/snpe/include/DiagLog/IDiagLog.hpp
new file mode 100644
index 00000000000000..a2bdbbdf7381c8
--- /dev/null
+++ b/phonelibs/snpe/include/DiagLog/IDiagLog.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8d410d1a52c77f81ac469eca4f2d9a589ae3f92fe36948ec84f42df0d6765387
+size 2234
diff --git a/phonelibs/snpe/include/DiagLog/Options.hpp b/phonelibs/snpe/include/DiagLog/Options.hpp
new file mode 100644
index 00000000000000..587a1b292f9269
--- /dev/null
+++ b/phonelibs/snpe/include/DiagLog/Options.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4fa35594e369531181b1220ed2bd7325d094e0696cf73e44a75f1e6860990978
+size 1970
diff --git a/phonelibs/snpe/include/DlContainer/IDlContainer.hpp b/phonelibs/snpe/include/DlContainer/IDlContainer.hpp
new file mode 100644
index 00000000000000..c1ccf0ddbe24c2
--- /dev/null
+++ b/phonelibs/snpe/include/DlContainer/IDlContainer.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6ec37f2fd4a1faade856e14c24a58793d814e760c0b1fd239415dfcdaa244df1
+size 4417
diff --git a/phonelibs/snpe/include/DlSystem/DlEnums.hpp b/phonelibs/snpe/include/DlSystem/DlEnums.hpp
new file mode 100644
index 00000000000000..aeced010b10142
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/DlEnums.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:90826fdd6a086879193075030b167115c0427e7c6f04a4fa8c5bc7a8f574e394
+size 3949
diff --git a/phonelibs/snpe/include/DlSystem/DlError.hpp b/phonelibs/snpe/include/DlSystem/DlError.hpp
new file mode 100644
index 00000000000000..8df03792465bdc
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/DlError.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d248c9f13e1a5b65f366076d5aafb0d015ed44edb4eed0045695919ffe0587c0
+size 8867
diff --git a/phonelibs/snpe/include/DlSystem/DlOptional.hpp b/phonelibs/snpe/include/DlSystem/DlOptional.hpp
new file mode 100644
index 00000000000000..3107116d9c4a23
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/DlOptional.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8a8d1e54e652b32f7cd2c1b230c979e634bf91751c320d197c5cb0d152d717ba
+size 5867
diff --git a/phonelibs/snpe/include/DlSystem/DlVersion.hpp b/phonelibs/snpe/include/DlSystem/DlVersion.hpp
new file mode 100644
index 00000000000000..4c28e1acbd3225
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/DlVersion.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e8da4c53f3a96b55205208002ddb517c53961bf15fdd20dd3afdf613daa0ea20
+size 2012
diff --git a/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp b/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp
new file mode 100644
index 00000000000000..c18a331c7bbf0a
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:eab3540ef39b2187ad475c7d5138eef98e4dfba1b0f00934f472b75e9a41882f
+size 1998
diff --git a/phonelibs/snpe/include/DlSystem/ITensor.hpp b/phonelibs/snpe/include/DlSystem/ITensor.hpp
new file mode 100644
index 00000000000000..8bcce1ed621261
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/ITensor.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:46907049c33a6abf7773d0671db5be11e902b6756cf437b9fcde746a0062e2f2
+size 4136
diff --git a/phonelibs/snpe/include/DlSystem/ITensorFactory.hpp b/phonelibs/snpe/include/DlSystem/ITensorFactory.hpp
new file mode 100644
index 00000000000000..c91769f6793565
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/ITensorFactory.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:37ab45b510a41a44568e5766c02b410a52516f9435c6d4534115ce377888fb6c
+size 2675
diff --git a/phonelibs/snpe/include/DlSystem/ITensorItr.hpp b/phonelibs/snpe/include/DlSystem/ITensorItr.hpp
new file mode 100644
index 00000000000000..d2adad7ee103ac
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/ITensorItr.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7fa8dc59fa5c5ec2db04bf2e51dd793cfa25b548c58d4399ceca5134df032b93
+size 5875
diff --git a/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp b/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp
new file mode 100644
index 00000000000000..89eb56058ce8f2
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b6981a330a5c68458a21e25659c7abad0e375d6c3a401b04c4a94705ba738b03
+size 1128
diff --git a/phonelibs/snpe/include/DlSystem/IUDL.hpp b/phonelibs/snpe/include/DlSystem/IUDL.hpp
new file mode 100644
index 00000000000000..fdaa7b197c2de7
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/IUDL.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d63d6651cb3f2133a456633df58952560eec0123b4929622cf8c8bf8692f8704
+size 2940
diff --git a/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp b/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp
new file mode 100644
index 00000000000000..fbe746588bd662
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b58f6e17d770d67438fc93c6c05612521b37fcc6f5939945eca5ab035e983c5e
+size 7607
diff --git a/phonelibs/snpe/include/DlSystem/IUserBufferFactory.hpp b/phonelibs/snpe/include/DlSystem/IUserBufferFactory.hpp
new file mode 100644
index 00000000000000..98294a1d35adde
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/IUserBufferFactory.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:786a163ab861e30141b7e199976fe29e16616774e5b0147a51535a206e72cc83
+size 2675
diff --git a/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp b/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp
new file mode 100644
index 00000000000000..0003fe7cdcf275
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:eb06f287c7eb174bda7a64723b6aab395eeececd6d67f386f92b228e44552e3f
+size 3873
diff --git a/phonelibs/snpe/include/DlSystem/String.hpp b/phonelibs/snpe/include/DlSystem/String.hpp
new file mode 100644
index 00000000000000..26d1c66067975c
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/String.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3c33456b51d8d2ffbec95166e97c5f32f67207b8ea27cbabec850b7d8dbb8c0d
+size 2490
diff --git a/phonelibs/snpe/include/DlSystem/StringList.hpp b/phonelibs/snpe/include/DlSystem/StringList.hpp
new file mode 100644
index 00000000000000..727c1f5a655510
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/StringList.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1174524a6beb8744727ae9c41e8fc89010b0c7147567b4747fa7ce8aafb6eadc
+size 2478
diff --git a/phonelibs/snpe/include/DlSystem/TensorMap.hpp b/phonelibs/snpe/include/DlSystem/TensorMap.hpp
new file mode 100644
index 00000000000000..e36c9256e0d3fd
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/TensorMap.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7223001d25503e47147f54c54cb4e92290ff3caf5e37198cccb978efb72f96f3
+size 2655
diff --git a/phonelibs/snpe/include/DlSystem/TensorShape.hpp b/phonelibs/snpe/include/DlSystem/TensorShape.hpp
new file mode 100644
index 00000000000000..07fcef1cb30d00
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/TensorShape.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b1c25bf90ccfa1ca6e9c9746de4a6287446058257719cced20328dc8136450dd
+size 4816
diff --git a/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp b/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp
new file mode 100644
index 00000000000000..d6c4758ebcac61
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a241a047b3fa8a35d29ef4ab6a44d909bc102b4bfed74f7383db9f19ea301a60
+size 2891
diff --git a/phonelibs/snpe/include/DlSystem/UDLContext.hpp b/phonelibs/snpe/include/DlSystem/UDLContext.hpp
new file mode 100644
index 00000000000000..9a4b5aed890893
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/UDLContext.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3cfa7f79e72744dce50bde7cb19d7ee6ad72c91044955fa263d52215511f00ff
+size 5901
diff --git a/phonelibs/snpe/include/DlSystem/UDLFunc.hpp b/phonelibs/snpe/include/DlSystem/UDLFunc.hpp
new file mode 100644
index 00000000000000..9a6117f3295cde
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/UDLFunc.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:099d0cd2b478957f93d6a8b8d2176cb6779c528389a48776d15976c65ecc3a82
+size 2424
diff --git a/phonelibs/snpe/include/DlSystem/UserBufferMap.hpp b/phonelibs/snpe/include/DlSystem/UserBufferMap.hpp
new file mode 100644
index 00000000000000..323287b8e4bc69
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/UserBufferMap.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2d31e9da6ceacb5aed9a554983b5e835399ce9cc2d6c35d2af591a8d18b94da9
+size 2911
diff --git a/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp b/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp
new file mode 100644
index 00000000000000..fe9f364c9b60fe
--- /dev/null
+++ b/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:74f2b0753011621fe91be4612a829cb494cb45703cf69c893cf4386076bb8e6e
+size 463
diff --git a/phonelibs/snpe/include/SNPE/SNPE.hpp b/phonelibs/snpe/include/SNPE/SNPE.hpp
new file mode 100644
index 00000000000000..74da1740a7d7a5
--- /dev/null
+++ b/phonelibs/snpe/include/SNPE/SNPE.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7de0a6ac247dd0733c6570110ab13ff5bf8aa12f3611a1fcfbcc39bd095758d3
+size 8122
diff --git a/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp b/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp
new file mode 100644
index 00000000000000..4f5195775175ca
--- /dev/null
+++ b/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ed0c2dea53b2fa092b3370321fb1f99893204e25e943a0bc2d151bddc0496fe2
+size 7192
diff --git a/phonelibs/snpe/include/SNPE/SNPEFactory.hpp b/phonelibs/snpe/include/SNPE/SNPEFactory.hpp
new file mode 100644
index 00000000000000..418631afdb5237
--- /dev/null
+++ b/phonelibs/snpe/include/SNPE/SNPEFactory.hpp
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:549be78486cbecaf16f42ece2b66bbc7c8cadd538c24e0ddbb25dd664bfaf42f
+size 2603
diff --git a/phonelibs/snpe/lib/.gitattributes b/phonelibs/snpe/lib/.gitattributes
new file mode 100644
index 00000000000000..72b93e3219e1ce
--- /dev/null
+++ b/phonelibs/snpe/lib/.gitattributes
@@ -0,0 +1,9 @@
+libc++_shared.so filter=lfs diff=lfs merge=lfs -text
+libsnpe_adsp.so filter=lfs diff=lfs merge=lfs -text
+libsnpe_dsp_domains.so filter=lfs diff=lfs merge=lfs -text
+libsnpe_dsp_domains_system.so filter=lfs diff=lfs merge=lfs -text
+libsnpe_dsp_domains_v2.so filter=lfs diff=lfs merge=lfs -text
+libSNPE_G.so filter=lfs diff=lfs merge=lfs -text
+libSNPE.so filter=lfs diff=lfs merge=lfs -text
+libsymphony-cpu.so filter=lfs diff=lfs merge=lfs -text
+libsymphonypower.so filter=lfs diff=lfs merge=lfs -text
diff --git a/phonelibs/snpe/lib/libSNPE.so b/phonelibs/snpe/lib/libSNPE.so
new file mode 100644
index 00000000000000..5cee2145e2d1db
--- /dev/null
+++ b/phonelibs/snpe/lib/libSNPE.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2df46d2204a3883ba2d3f4481d5d813982033a267ee69f239d146434ac0543a8
+size 5227664
diff --git a/phonelibs/snpe/lib/libSNPE_G.so b/phonelibs/snpe/lib/libSNPE_G.so
new file mode 100644
index 00000000000000..dc2dc388de1000
--- /dev/null
+++ b/phonelibs/snpe/lib/libSNPE_G.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1901c3f88ae18db1c10ee327c0060974a7b2e3b84b98bb4ddec2ffa89290da81
+size 4179504
diff --git a/phonelibs/snpe/lib/libc++_shared.so b/phonelibs/snpe/lib/libc++_shared.so
new file mode 100644
index 00000000000000..ee7fea00e03671
--- /dev/null
+++ b/phonelibs/snpe/lib/libc++_shared.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e689b38c7e47b309a04b8850e93d68545eb7813498680e68a9ea20bae47efb89
+size 6624168
diff --git a/phonelibs/snpe/lib/libsnpe_adsp.so b/phonelibs/snpe/lib/libsnpe_adsp.so
new file mode 100644
index 00000000000000..5a9794c7717d6f
--- /dev/null
+++ b/phonelibs/snpe/lib/libsnpe_adsp.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:aa79ec0b7f1d286b642a29468e93db82e343d2c62f0aae2594390c31a0a01548
+size 17720
diff --git a/phonelibs/snpe/lib/libsnpe_dsp_domains.so b/phonelibs/snpe/lib/libsnpe_dsp_domains.so
new file mode 100644
index 00000000000000..f005705a5288c0
--- /dev/null
+++ b/phonelibs/snpe/lib/libsnpe_dsp_domains.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bb3a6baf73d5977e4a30cf60429f4feb765b9bd8d3efebd29ff82ba73ff34201
+size 17640
diff --git a/phonelibs/snpe/lib/libsnpe_dsp_domains_system.so b/phonelibs/snpe/lib/libsnpe_dsp_domains_system.so
new file mode 100644
index 00000000000000..734638007c22fc
--- /dev/null
+++ b/phonelibs/snpe/lib/libsnpe_dsp_domains_system.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:47d0916a6b322330620be184c36bae7681678287408c96360d70d40f90d6b41e
+size 17640
diff --git a/phonelibs/snpe/lib/libsnpe_dsp_domains_v2.so b/phonelibs/snpe/lib/libsnpe_dsp_domains_v2.so
new file mode 100644
index 00000000000000..74736813ebbea3
--- /dev/null
+++ b/phonelibs/snpe/lib/libsnpe_dsp_domains_v2.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c64301531edbb3471b70df6dc31901a5de9d907649db4948577d0cfc9b4016bd
+size 17648
diff --git a/phonelibs/snpe/lib/libsymphony-cpu.so b/phonelibs/snpe/lib/libsymphony-cpu.so
new file mode 100755
index 00000000000000..0d45f2f603d13e
--- /dev/null
+++ b/phonelibs/snpe/lib/libsymphony-cpu.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:40990fbd09c217301cb5a89c20e401e1dcb9a86b99a7d9436cf2c995ad15952e
+size 518000
diff --git a/phonelibs/snpe/lib/libsymphonypower.so b/phonelibs/snpe/lib/libsymphonypower.so
new file mode 100755
index 00000000000000..f8a6771749162c
--- /dev/null
+++ b/phonelibs/snpe/lib/libsymphonypower.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cf93a6e8ab2a1df4ab3fcac92b277489be8258682b7e15884b55f2b21bfacb29
+size 54960
diff --git a/phonelibs/zlib/build.txt b/phonelibs/zlib/build.txt
new file mode 100644
index 00000000000000..a8312ac22122f4
--- /dev/null
+++ b/phonelibs/zlib/build.txt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ceed041aa79cbd6641c5ac8d482728b44267d77fbbc0db46d3932320e84a9dde
+size 147
diff --git a/phonelibs/zlib/lib/libz.a b/phonelibs/zlib/lib/libz.a
new file mode 100644
index 00000000000000..f7e6559b809f93
--- /dev/null
+++ b/phonelibs/zlib/lib/libz.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:00411a70d46e88d8946cc834756f627ac9a9aa5ca1df0af298c1ccc6697a46a0
+size 909456
diff --git a/phonelibs/zmq/aarch64-linux/bin/curve_keygen b/phonelibs/zmq/aarch64-linux/bin/curve_keygen
new file mode 100755
index 00000000000000..7d83874f5f5799
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/bin/curve_keygen
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:20f4a2b629bf70323244ae8b2df3ccfe182fbdbf2cf1643860e454bc4ea9e7d1
+size 13048
diff --git a/phonelibs/zmq/aarch64-linux/include/czmq.h b/phonelibs/zmq/aarch64-linux/include/czmq.h
new file mode 100644
index 00000000000000..2b3bf3ea5b142f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/czmq.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e434c73611bb5576b3a9b1a6a40bce70a5ecbe36ea1a510392a2935196af0569
+size 1275
diff --git a/phonelibs/zmq/aarch64-linux/include/czmq_library.h b/phonelibs/zmq/aarch64-linux/include/czmq_library.h
new file mode 100644
index 00000000000000..e3b5a35c09061d
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/czmq_library.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7a7c22cb33dcd531a21837dc70103043012f7b29d1f5b1b7aaf430f9034ef6f9
+size 5539
diff --git a/phonelibs/zmq/aarch64-linux/include/czmq_prelude.h b/phonelibs/zmq/aarch64-linux/include/czmq_prelude.h
new file mode 100644
index 00000000000000..48faa989c0b2fa
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/czmq_prelude.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c6866da03dbd52cfd3eb2b3cd1fcbce6d81756d0d573590065d4a42f212a9356
+size 19294
diff --git a/phonelibs/zmq/aarch64-linux/include/zactor.h b/phonelibs/zmq/aarch64-linux/include/zactor.h
new file mode 100644
index 00000000000000..b29ec9afe1b1ee
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zactor.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f5e5e9e2086688abc765e0c13d6621b7648d0a5fe41446af777f9f192fbaeb29
+size 2473
diff --git a/phonelibs/zmq/aarch64-linux/include/zarmour.h b/phonelibs/zmq/aarch64-linux/include/zarmour.h
new file mode 100644
index 00000000000000..44f6ba24fb4509
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zarmour.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f9696bd0aea94f596a6ad7083b72e7fc30c31b0da16d5731225a31d1c2c4ee11
+size 3644
diff --git a/phonelibs/zmq/aarch64-linux/include/zauth.h b/phonelibs/zmq/aarch64-linux/include/zauth.h
new file mode 100644
index 00000000000000..493cc40195643c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zauth.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4a97a24653ef009fb968102d4d4a41fe2bde9efea9d0d9cfffe1abb14b4cf592
+size 3611
diff --git a/phonelibs/zmq/aarch64-linux/include/zbeacon.h b/phonelibs/zmq/aarch64-linux/include/zbeacon.h
new file mode 100644
index 00000000000000..dd238d8abd15ac
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zbeacon.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c4212faea9f2a2f7ba343cc02987fd96deffe8e23dee35e2c0a088841abffecb
+size 2856
diff --git a/phonelibs/zmq/aarch64-linux/include/zcert.h b/phonelibs/zmq/aarch64-linux/include/zcert.h
new file mode 100644
index 00000000000000..19f4fe553f74a1
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zcert.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:450ea0eab5a4fd081d1face3cb4991cbdae8a05721493e5f8a099be208b2515b
+size 4283
diff --git a/phonelibs/zmq/aarch64-linux/include/zcertstore.h b/phonelibs/zmq/aarch64-linux/include/zcertstore.h
new file mode 100644
index 00000000000000..311f70ebdd89ad
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zcertstore.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:be988dcc7301ebd693f1485cbe60d22d7cecc2d9fb6d986eadfded77678ff74c
+size 3567
diff --git a/phonelibs/zmq/aarch64-linux/include/zchunk.h b/phonelibs/zmq/aarch64-linux/include/zchunk.h
new file mode 100644
index 00000000000000..dc923ae56ac3d3
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zchunk.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c5391efa3017a3fd4d90b73f661e43f0b0664052520f4f983b38766376521d7b
+size 5899
diff --git a/phonelibs/zmq/aarch64-linux/include/zclock.h b/phonelibs/zmq/aarch64-linux/include/zclock.h
new file mode 100644
index 00000000000000..28846600750077
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zclock.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7f3f0c545553e4cef2115043f5ba58f5c856889c215fe123ed95d46dae14dfa5
+size 2465
diff --git a/phonelibs/zmq/aarch64-linux/include/zconfig.h b/phonelibs/zmq/aarch64-linux/include/zconfig.h
new file mode 100644
index 00000000000000..7382618626d985
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zconfig.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e9b32a750b627e4a621ab3e9a4cefe64b3a367da091b8757450791e8d9361c2b
+size 6591
diff --git a/phonelibs/zmq/aarch64-linux/include/zdigest.h b/phonelibs/zmq/aarch64-linux/include/zdigest.h
new file mode 100644
index 00000000000000..bce0ecf8292ffa
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zdigest.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:22a41bbe93e99cca59fe8d1617fb27b336cd2c4f2d094b4eea95f98e3470fce3
+size 2069
diff --git a/phonelibs/zmq/aarch64-linux/include/zdir.h b/phonelibs/zmq/aarch64-linux/include/zdir.h
new file mode 100644
index 00000000000000..663530347883c5
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zdir.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4ea8ae429fee870ac8c605fe28adf604d7dd22109360f7c089471ec9f07f754d
+size 6129
diff --git a/phonelibs/zmq/aarch64-linux/include/zdir_patch.h b/phonelibs/zmq/aarch64-linux/include/zdir_patch.h
new file mode 100644
index 00000000000000..1157d28dca4217
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zdir_patch.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bdf4336095870dba4e5fdb89a7867b26b61a879cf4c0631dab857ebbee79ff9f
+size 2422
diff --git a/phonelibs/zmq/aarch64-linux/include/zfile.h b/phonelibs/zmq/aarch64-linux/include/zfile.h
new file mode 100644
index 00000000000000..6c0b217987a14f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zfile.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a66c39280771660524a50e359e2adc6f35df35a11d6cf7d922740e2d3b34e04a
+size 6250
diff --git a/phonelibs/zmq/aarch64-linux/include/zframe.h b/phonelibs/zmq/aarch64-linux/include/zframe.h
new file mode 100644
index 00000000000000..58a74b27c2559f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zframe.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6f3b444f0b237c105a7aaef90ba2e09609e5d06a5a278c6cc5a6b8a1aa6c9752
+size 6538
diff --git a/phonelibs/zmq/aarch64-linux/include/zgossip.h b/phonelibs/zmq/aarch64-linux/include/zgossip.h
new file mode 100644
index 00000000000000..c49417587ddc3c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zgossip.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:132f3c042ffc2a056405a6857a66ec6bfe40fad7edfc3229ef6b833407a0bfe3
+size 2964
diff --git a/phonelibs/zmq/aarch64-linux/include/zhash.h b/phonelibs/zmq/aarch64-linux/include/zhash.h
new file mode 100644
index 00000000000000..ae77b94364ee3d
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zhash.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ad6a1d63f4059cd6dd9c18eae4afd6a449c6f1ae4b03a1b697af79708612b9e1
+size 8178
diff --git a/phonelibs/zmq/aarch64-linux/include/zhashx.h b/phonelibs/zmq/aarch64-linux/include/zhashx.h
new file mode 100644
index 00000000000000..5790f7141d239a
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zhashx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d163c60813069859c1c8ea94e07f7769f35b406147abc342d3dbb9448cfb8dc9
+size 12557
diff --git a/phonelibs/zmq/aarch64-linux/include/ziflist.h b/phonelibs/zmq/aarch64-linux/include/ziflist.h
new file mode 100644
index 00000000000000..0a01a19c621dc6
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/ziflist.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3df305f973face711a307384a310bbe3d74afbd06fc263e4fe78e6886244df73
+size 2256
diff --git a/phonelibs/zmq/aarch64-linux/include/zlist.h b/phonelibs/zmq/aarch64-linux/include/zlist.h
new file mode 100644
index 00000000000000..19376fb3d744c9
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zlist.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:23ca4ea43fe89ef066c42c0524b21bb2f3857bda386f8df8109f69cb25f13cc4
+size 6202
diff --git a/phonelibs/zmq/aarch64-linux/include/zlistx.h b/phonelibs/zmq/aarch64-linux/include/zlistx.h
new file mode 100644
index 00000000000000..df1ab07816da47
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zlistx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:382c7fa2cfdcb3efdf1631ba6ba1f97bb03297c102cf6e629c3db8519e946a0e
+size 8547
diff --git a/phonelibs/zmq/aarch64-linux/include/zloop.h b/phonelibs/zmq/aarch64-linux/include/zloop.h
new file mode 100644
index 00000000000000..394f0f16dc5a40
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zloop.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:32aa6915cea28c1a7b1bd360d0dc7d4981ace423a126c8708718d5058893289d
+size 7185
diff --git a/phonelibs/zmq/aarch64-linux/include/zmonitor.h b/phonelibs/zmq/aarch64-linux/include/zmonitor.h
new file mode 100644
index 00000000000000..21c138037f9e9f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zmonitor.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8c4004636f31648f98050e637daa231c70fcf4b64da326548b4f50dccba5ceb1
+size 1889
diff --git a/phonelibs/zmq/aarch64-linux/include/zmq.h b/phonelibs/zmq/aarch64-linux/include/zmq.h
new file mode 100644
index 00000000000000..f70ef9d7f4574b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zmq.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e00ab4b318526fc2b340ca69cafcd5e5071810f63471a0fe89064ee18e1afafb
+size 24177
diff --git a/phonelibs/zmq/aarch64-linux/include/zmq_utils.h b/phonelibs/zmq/aarch64-linux/include/zmq_utils.h
new file mode 100644
index 00000000000000..947923e6dd9a62
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zmq_utils.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:926abbe8a8ab28df17746ca5bf60440b799b391be172c406e0628cdef3788909
+size 2316
diff --git a/phonelibs/zmq/aarch64-linux/include/zmsg.h b/phonelibs/zmq/aarch64-linux/include/zmsg.h
new file mode 100644
index 00000000000000..4a9b43ae945716
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zmsg.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1e08ea0a57a0cede5c2860dd447d5452226b61de22dc778e6e6c602ee940ad20
+size 11537
diff --git a/phonelibs/zmq/aarch64-linux/include/zpoller.h b/phonelibs/zmq/aarch64-linux/include/zpoller.h
new file mode 100644
index 00000000000000..9ece76cf03be75
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zpoller.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1b2af935bab05d478ed103138e5a0b5ddce85a270de2eef73c474155a93f612c
+size 3453
diff --git a/phonelibs/zmq/aarch64-linux/include/zproxy.h b/phonelibs/zmq/aarch64-linux/include/zproxy.h
new file mode 100644
index 00000000000000..04dd99d8031efa
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zproxy.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:61798dbd369cfefd3a90376818f628107bff9131d95cc8b444a924c28cb06115
+size 3889
diff --git a/phonelibs/zmq/aarch64-linux/include/zrex.h b/phonelibs/zmq/aarch64-linux/include/zrex.h
new file mode 100644
index 00000000000000..48f2dd46765e07
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zrex.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5aa3120214f9fa79436f9b5ed4db050a5974d774dd99bd0e9bba13f70f04be6d
+size 2903
diff --git a/phonelibs/zmq/aarch64-linux/include/zsock.h b/phonelibs/zmq/aarch64-linux/include/zsock.h
new file mode 100644
index 00000000000000..738d1d69f8c06b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zsock.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b1e1908455d9810980fb5c9de6726c33a327ff71976d08f696860cd506087c6c
+size 44814
diff --git a/phonelibs/zmq/aarch64-linux/include/zstr.h b/phonelibs/zmq/aarch64-linux/include/zstr.h
new file mode 100644
index 00000000000000..1aaf84f04d0d5f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zstr.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ea6f83ec5aa4ae69d95a991f0a9c8912b7f8e1c23db1d73be934c80e086f783a
+size 4557
diff --git a/phonelibs/zmq/aarch64-linux/include/zsys.h b/phonelibs/zmq/aarch64-linux/include/zsys.h
new file mode 100644
index 00000000000000..adc1da73ef0161
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zsys.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0848d4218ef47604f36f365d1ee83727f2a03494c53a58475803b5f36437c5e6
+size 16109
diff --git a/phonelibs/zmq/aarch64-linux/include/zuuid.h b/phonelibs/zmq/aarch64-linux/include/zuuid.h
new file mode 100644
index 00000000000000..4676899834a87c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/include/zuuid.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6de67e7d53ebbffefe2c330bded67425df97d8bb5d79717d0227e3b6fb1899f9
+size 2790
diff --git a/phonelibs/zmq/aarch64-linux/lib/libczmq.a b/phonelibs/zmq/aarch64-linux/lib/libczmq.a
new file mode 100644
index 00000000000000..70680fa617e2e7
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libczmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9d7ee1202b89be647edcceaccbcbfd6777b6944b7c169bd28118c0a1710de22b
+size 1172240
diff --git a/phonelibs/zmq/aarch64-linux/lib/libczmq.la b/phonelibs/zmq/aarch64-linux/lib/libczmq.la
new file mode 100755
index 00000000000000..08b9fd3e183296
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libczmq.la
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9a8e4870eb46d2ad7f1df5823b42c4310e05ace540db4f546ce5df740e06eb97
+size 1053
diff --git a/phonelibs/zmq/aarch64-linux/lib/libczmq.so b/phonelibs/zmq/aarch64-linux/lib/libczmq.so
new file mode 120000
index 00000000000000..db9aa60f9b5868
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libczmq.so
@@ -0,0 +1 @@
+libczmq.so.4.0.2
\ No newline at end of file
diff --git a/phonelibs/zmq/aarch64-linux/lib/libczmq.so.4 b/phonelibs/zmq/aarch64-linux/lib/libczmq.so.4
new file mode 120000
index 00000000000000..db9aa60f9b5868
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libczmq.so.4
@@ -0,0 +1 @@
+libczmq.so.4.0.2
\ No newline at end of file
diff --git a/phonelibs/zmq/aarch64-linux/lib/libczmq.so.4.0.2 b/phonelibs/zmq/aarch64-linux/lib/libczmq.so.4.0.2
new file mode 100755
index 00000000000000..de760a61fd3511
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libczmq.so.4.0.2
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0f8440c27b9323413721f07e206597c53209c6b311c735e046c30b6f211665d2
+size 544808
diff --git a/phonelibs/zmq/aarch64-linux/lib/libzmq.a b/phonelibs/zmq/aarch64-linux/lib/libzmq.a
new file mode 100644
index 00000000000000..b6bd2ab734d3d8
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libzmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0f7c6db2f4cbd86282f952cc64a570416220e5c7bc4dff96e3a436a778b59730
+size 27918754
diff --git a/phonelibs/zmq/aarch64-linux/lib/libzmq.la b/phonelibs/zmq/aarch64-linux/lib/libzmq.la
new file mode 100755
index 00000000000000..c53516d035aae5
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libzmq.la
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c5b2b3ec08b209a69bd83ad5339d00ba0e60ff0fc0f511666b06d4895e7eed09
+size 966
diff --git a/phonelibs/zmq/aarch64-linux/lib/libzmq.so b/phonelibs/zmq/aarch64-linux/lib/libzmq.so
new file mode 120000
index 00000000000000..ef44cafc6ac861
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libzmq.so
@@ -0,0 +1 @@
+libzmq.so.5.1.2
\ No newline at end of file
diff --git a/phonelibs/zmq/aarch64-linux/lib/libzmq.so.5 b/phonelibs/zmq/aarch64-linux/lib/libzmq.so.5
new file mode 120000
index 00000000000000..ef44cafc6ac861
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libzmq.so.5
@@ -0,0 +1 @@
+libzmq.so.5.1.2
\ No newline at end of file
diff --git a/phonelibs/zmq/aarch64-linux/lib/libzmq.so.5.1.2 b/phonelibs/zmq/aarch64-linux/lib/libzmq.so.5.1.2
new file mode 100755
index 00000000000000..142923c3f142d1
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/libzmq.so.5.1.2
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4e9cbc07c0c92b14930f664beda8da1b7fec88d51bec474b987850e43c65abf8
+size 8927592
diff --git a/phonelibs/zmq/aarch64-linux/lib/pkgconfig/libczmq.pc b/phonelibs/zmq/aarch64-linux/lib/pkgconfig/libczmq.pc
new file mode 100644
index 00000000000000..60497ab6b9c53f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/pkgconfig/libczmq.pc
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:890b19a472b79e3e25cb5efe3485cff16c65f9a8ac887ad1e6738d06efc28c26
+size 929
diff --git a/phonelibs/zmq/aarch64-linux/lib/pkgconfig/libzmq.pc b/phonelibs/zmq/aarch64-linux/lib/pkgconfig/libzmq.pc
new file mode 100644
index 00000000000000..0908750327cfc0
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/lib/pkgconfig/libzmq.pc
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:662b0ac99fece95caa0f263364be0ac4e8a831e7fa72e26617928e6c06f8b6ec
+size 238
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man1/zmakecert.1 b/phonelibs/zmq/aarch64-linux/share/man/man1/zmakecert.1
new file mode 100644
index 00000000000000..ce67408923a42a
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man1/zmakecert.1
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c6d1918afeb8335867f56d2d0d78484fbb793e4e47da8784e8ba38ff2b877573
+size 2576
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zactor.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zactor.3
new file mode 100644
index 00000000000000..ec5cf961b607da
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zactor.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1a4ea139c060c364b0f143ede4d8859dc7f1706380c36b86a828fd32d6625538
+size 4948
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zarmour.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zarmour.3
new file mode 100644
index 00000000000000..a02314f5966d06
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zarmour.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:de4d31fa069eff52350eeeeaef50ad16716d8238cf7c9c1a1a58717ff4320fa5
+size 14198
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zauth.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zauth.3
new file mode 100644
index 00000000000000..2b30ba59b6920d
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zauth.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:23474e4b01d47fdcbde596b0530ce9eae731a9563c17c4ce88dc8e608ff2d54d
+size 11372
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zbeacon.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zbeacon.3
new file mode 100644
index 00000000000000..68f264599b298f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zbeacon.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8144519498fa70f68a6787277f07f20fcf10e4b3e3609b3ae5a773dc5c94d15f
+size 8208
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zcert.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zcert.3
new file mode 100644
index 00000000000000..e3989160061bd3
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zcert.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7887ca6da2ebec62c0e90c8ac06a6a7616fb48f51a4a94fd477b3d2e5beaa01d
+size 8160
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zcertstore.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zcertstore.3
new file mode 100644
index 00000000000000..f3058b3958e9b2
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zcertstore.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:653423dfad509e4b2380e2c88b417da3180194ed680d0bf67ac7036b25cb6bfd
+size 7400
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zchunk.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zchunk.3
new file mode 100644
index 00000000000000..7abafbf85d1b97
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zchunk.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a769eefb94ebb22cc0f5326c3cd4172babee9b12f7aa3783cebeb34c76c49b0b
+size 9519
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zclock.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zclock.3
new file mode 100644
index 00000000000000..72f4bdb129c9f9
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zclock.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b6322cde6b8789aabad3fa63aa51449658aa7eede0980119bd026e6863b8a88e
+size 4232
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zconfig.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zconfig.3
new file mode 100644
index 00000000000000..0a51e40d147cfe
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zconfig.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:83f13ff63832a62890946a560df1d0d5995f33a44835bd3f3b30923459e2c32a
+size 10878
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zdigest.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zdigest.3
new file mode 100644
index 00000000000000..dd74eec449ef63
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zdigest.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8da6be01b2ce4dda42fd9e307d0798f7f532826b4cbf83fd1bf26bd35622cd85
+size 4213
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zdir.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zdir.3
new file mode 100644
index 00000000000000..2f9e7475176c7c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zdir.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:df211896606dbf2e6c2b4384c46ce6da295ed03d650a735cae55c27d0fed7e15
+size 9357
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zdir_patch.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zdir_patch.3
new file mode 100644
index 00000000000000..6d9ab0db66162f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zdir_patch.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bf0a78501e34bb6e2f9a500420d5ce7af1da0bab113c185cbb4d9475296a5ba3
+size 4214
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zfile.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zfile.3
new file mode 100644
index 00000000000000..c9c51116c61e9e
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zfile.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1f66288b4ca4c5eed0d09bd8390dc534b9f86a21f9ecf807b477681b881f7282
+size 11586
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zframe.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zframe.3
new file mode 100644
index 00000000000000..5c48f4c5b103f1
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zframe.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ab8e68d9bcf65dad60609689a4a799f064b20f4a7bd2d22e0045d890e523234b
+size 11825
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zgossip.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zgossip.3
new file mode 100644
index 00000000000000..70c3620c91b6a7
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zgossip.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e3751249c9f9596b84bf57e8b91f27411a12b002fc8b85f84167e4aaca6d21f8
+size 10238
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zhash.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zhash.3
new file mode 100644
index 00000000000000..f052a103ca998a
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zhash.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3debb724f3d52dd4e021f9494b096cffef574d0a2cc75ce8d51f540ba7caaeaa
+size 13900
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zhashx.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zhashx.3
new file mode 100644
index 00000000000000..01151a76e0838b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zhashx.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac49fbed0addf5b7174262b2ee1d55ea69d97b9107ecebfb32b23a1944c64842
+size 18796
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/ziflist.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/ziflist.3
new file mode 100644
index 00000000000000..9997cc9267e319
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/ziflist.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:380d8d1b5c43d1daed9f148d6635f19b05a939f0b3e104c27e6df6f10a51f727
+size 4624
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zlist.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zlist.3
new file mode 100644
index 00000000000000..59045d85a497c0
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zlist.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f938ebd768fbda9079fca2eb66b7985fb40b86c874cef383d642233a057894ba
+size 11230
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zlistx.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zlistx.3
new file mode 100644
index 00000000000000..8783af203141ec
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zlistx.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ec881dfb5263f7fd315a68ba9486bda278517c245d1449cb2e443453bbf4abc0
+size 13309
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zloop.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zloop.3
new file mode 100644
index 00000000000000..7db74e724691b4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zloop.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5661deb2b79120ac911775153f489f10a3194244304958e15732a10dcfe2efe8
+size 10215
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmonitor.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmonitor.3
new file mode 100644
index 00000000000000..cabfca10c61457
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmonitor.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c58ac95ee0e589af9a6503f060497d4f40df86b70c54f6b712a5cb7584c0a499
+size 5113
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_dec.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_dec.3
new file mode 100644
index 00000000000000..6a6fb502488edc
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_dec.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e947a67fe6072e8e4a47530677454c10fb24a5ddf622ef8663403b0b58818e9b
+size 2810
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_destroy.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_destroy.3
new file mode 100644
index 00000000000000..2a8bd49d9210b4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_destroy.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a98d994b0e42e4e3fcd4a8798efe52bb3669507197c56f4009f87ac3c0ff26ea
+size 2904
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_inc.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_inc.3
new file mode 100644
index 00000000000000..ad4c75a0f175cf
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_inc.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6f6f0096366fcc85ed11db69d717b1955fa7aefa27b32cac08a0cf7bc3c595e2
+size 2766
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_new.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_new.3
new file mode 100644
index 00000000000000..3cc59415936eb2
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_new.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:913064457daa55f4a334f2eb3733be64147f6dddea5eb5853d67298da3d10670
+size 2906
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_set.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_set.3
new file mode 100644
index 00000000000000..b0421542dbebbc
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_set.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:09e0b5231d9d823917b49da0486c623f83574b263eeb7579649d3b003ee3889d
+size 2828
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_value.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_value.3
new file mode 100644
index 00000000000000..7becb10e0e23d5
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_atomic_counter_value.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:eb9a6c4d2dd4d57b50bf31f734fd5c71af34f7ac720b5d6ae5531bf8c814189c
+size 2779
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_bind.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_bind.3
new file mode 100644
index 00000000000000..49a424335a23e7
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_bind.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f9af3b2e22ce686e572d585c28d9931017907d06cfbf515d76dba38fe44e3d51
+size 5214
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_close.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_close.3
new file mode 100644
index 00000000000000..7f52bfe208dc2f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_close.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8380b6e243e3a434bb4e61151e6bc43a0be93c1143b785cec696bc49def0b6b2
+size 2725
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_connect.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_connect.3
new file mode 100644
index 00000000000000..de4b839510f4b2
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_connect.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a2d8fd7b348f9256e6dcf6d3055e21cd776caa11c8307ba04d3e655c8ac52de8
+size 5382
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_get.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_get.3
new file mode 100644
index 00000000000000..f59da46df6e520
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_get.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:31da76fdd01ba6dafba58553cc69fbd96914b70c8f1888b50ba528428864bc94
+size 3881
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_new.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_new.3
new file mode 100644
index 00000000000000..7f83927e7e7660
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_new.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:36944b6963857e283cf47e842f15e6841edbf582ba350393e42f4e4878184de9
+size 2240
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_set.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_set.3
new file mode 100644
index 00000000000000..898c518511521e
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_set.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cd8105cb3e76b5a899ff0bf4edc6ed966c3dada4b3b3771480640efb8d12e1fc
+size 5744
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_shutdown.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_shutdown.3
new file mode 100644
index 00000000000000..ac1dd04f5bac2b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_shutdown.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2c4b6a1c94f48e1e064f99762cbeeee277bcaa0e3bc1f15296480832a7ea993b
+size 2492
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_term.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_term.3
new file mode 100644
index 00000000000000..3b4384d6ebc833
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_ctx_term.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f2d8149c50015a5898916bfef67ba7a5ab3348ba2b54ee86b1e39773ef74484e
+size 3437
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_curve_keypair.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_curve_keypair.3
new file mode 100644
index 00000000000000..2e9e6caac0330b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_curve_keypair.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bc6004d30c73c808ed0e88939963728c31a2be471f0fd62a2fbea2c8ab857769
+size 2483
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_curve_public.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_curve_public.3
new file mode 100644
index 00000000000000..b18f0270c96d87
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_curve_public.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:174e364242de0bb118ea1703a66b0d256120af51403edbb996eccf4ed203483b
+size 2715
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_disconnect.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_disconnect.3
new file mode 100644
index 00000000000000..42b9bdcd279a70
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_disconnect.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b60296e3c3acc35fdbeef03fcf1e3bbe90c867a96d55d96135e4e353379660f6
+size 3655
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_errno.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_errno.3
new file mode 100644
index 00000000000000..525907f6e8e77b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_errno.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:283266581ae929083811bf2e2da011486eb97235122d7410e06a5d6a7bbaa5b3
+size 2528
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_getsockopt.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_getsockopt.3
new file mode 100644
index 00000000000000..94bb25b70aaa9b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_getsockopt.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:02fffdbbbb91557666f78dd4089277f61261ed400289f2baf4b9910e2cc55d2e
+size 38492
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_has.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_has.3
new file mode 100644
index 00000000000000..11e3ff79776d97
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_has.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7c06c30b004555e1f1dcc1097eba8a7d55f4c14b6b000c6cc8ee1a16439d58f6
+size 2983
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_close.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_close.3
new file mode 100644
index 00000000000000..926f0803ff14d5
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_close.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2f83f56dc0b1558d152cdd1a606ddd3b19fdb26931fb834bf5dd155961b8934a
+size 2784
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_copy.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_copy.3
new file mode 100644
index 00000000000000..6ab604e1b707fa
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_copy.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ddff021b17a6515e1412a81ad31025219f716d8663ff120a96ea984fa6582886
+size 3378
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_data.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_data.3
new file mode 100644
index 00000000000000..8cf5c3da1b05b8
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_data.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:62c781fdf04b4545c0ed1168f17933bef458e1ef00a64c60de3961e2a9099a15
+size 2250
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_get.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_get.3
new file mode 100644
index 00000000000000..02a5c6605746be
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_get.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:205202fe6cffcc8a7cebc89614a3db2be41a02f71f0edd36f47cc9e7c0bf047c
+size 3343
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_gets.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_gets.3
new file mode 100644
index 00000000000000..64e8e82c9c31c3
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_gets.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2d4d8cb4646a66bfa837dc95505fee8d9fc34366a7a054d1df581b9623a47b37
+size 3301
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init.3
new file mode 100644
index 00000000000000..fe18b5b2635839
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:553edd04caf71a82d5f3d34349c57a15779e9370c77512ba7f63947a07d12725
+size 2831
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init_data.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init_data.3
new file mode 100644
index 00000000000000..cd620b6cbb9ed4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init_data.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:dcbb4284f5f790ad2ab7904cd95a8097fcbbbf8c7ab556626b65d27a386dc11d
+size 4151
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init_size.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init_size.3
new file mode 100644
index 00000000000000..f1d7fd15c1ae2a
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_init_size.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:50799dcfe68c173d791d755830d0c5fd1581f106366e1b5d93fc61a3d34e33ea
+size 3019
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_more.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_more.3
new file mode 100644
index 00000000000000..0894af40c557e4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_more.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:deaa26978f0a7c71ee02e5b187a00d87f39cb636e1c4f35f36401841b87f5dac
+size 2771
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_move.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_move.3
new file mode 100644
index 00000000000000..7ddd3f0f9d1bf0
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_move.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a3806ccc5980397cb9a12545cb4f624b2888ad81d1d6dccd95a845470031f12a
+size 2642
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_recv.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_recv.3
new file mode 100644
index 00000000000000..a841a9a49adfd6
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_recv.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8e757fc6576268c73ada043f2bc500694d11a0b1d3155e247e0cd81a824e5e5e
+size 5405
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_routing_id.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_routing_id.3
new file mode 100644
index 00000000000000..84b10c14a8f5d6
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_routing_id.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:99d220007b2ae36283bd172df673d6729298f7c8ea4632c396a02f40f069bd4f
+size 2688
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_send.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_send.3
new file mode 100644
index 00000000000000..043dfaaff21790
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_send.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:06f9ed84d1dc2dd12ec5dac9e4905fa1eb3b3262cbd3a861be587a964cd266c0
+size 6002
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_set.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_set.3
new file mode 100644
index 00000000000000..c760b5b9520b2b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_set.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4d3feb4667e18a297b05b82d07e29d0154560fe09df11620d1748a52f1e5536c
+size 2230
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_set_routing_id.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_set_routing_id.3
new file mode 100644
index 00000000000000..95e9aa91dc3682
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_set_routing_id.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f7cc6c0a567ce9196800f75c634214e63ecf5688f1c4b8fcf8934097ee708bb8
+size 2331
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_size.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_size.3
new file mode 100644
index 00000000000000..46da55a1912ec2
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_msg_size.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3a728d8583de76a2d0fcfb4ba1bbb739d811fb43b5dbcfe65646b5aa2e1a56c3
+size 2262
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_poll.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_poll.3
new file mode 100644
index 00000000000000..8de6a72317fe46
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_poll.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f824a0e8f7a86d037e69fb50bd0aac6043906cb6b8fa56535827aa3b0e6049e8
+size 6590
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_proxy.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_proxy.3
new file mode 100644
index 00000000000000..ec8f5abed8bb74
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_proxy.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bce453ba36bf3bb4b5734c63e6f4437e9f31e3fc7ddbb5e959eab52dc89b8915
+size 4476
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_proxy_steerable.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_proxy_steerable.3
new file mode 100644
index 00000000000000..0b0b550e82136a
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_proxy_steerable.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:07c74f41c2da639a6a2f1bec137c93b425bd2bb03f4a035c1eae1981bcbb523b
+size 4313
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_recv.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_recv.3
new file mode 100644
index 00000000000000..1616344f606a80
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_recv.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3e33829ccff17f3c30606cabec1cf1c9e125cf7ac15f162c4fb246fe91cf9df0
+size 4374
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_recvmsg.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_recvmsg.3
new file mode 100644
index 00000000000000..96b41177716621
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_recvmsg.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f08ce67256b46dbd7c585b31271f730e35ed430b92436ac133878ae66a33aea8
+size 5352
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_send.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_send.3
new file mode 100644
index 00000000000000..83129bf29807f2
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_send.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:13d3d10976e2a2f9670a606e90a2377461c89024751238cd46535fb90e4b4089
+size 4923
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_send_const.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_send_const.3
new file mode 100644
index 00000000000000..0ea1bb343c787c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_send_const.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bb6c3e591e95b58e5dfe8d0887c423296ba2f9dbf6daf53a394d93cbc8b3f869
+size 5019
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_sendmsg.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_sendmsg.3
new file mode 100644
index 00000000000000..1bd9c6d7c6fd7a
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_sendmsg.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:70bdfe033a9a13662fc00bfdbbc72126690b7eb371ae6fe00b3686317655922e
+size 5840
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_setsockopt.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_setsockopt.3
new file mode 100644
index 00000000000000..f88239254763e0
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_setsockopt.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:daa21e2c97698d8dd96483017b8f4c531b655cc08b07fff35fbfa5724f9f4047
+size 56701
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_socket.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_socket.3
new file mode 100644
index 00000000000000..789d4b2f568f72
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_socket.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1b417dc3195251680f5c77d86cd7d3bcc278a24007b160e6d069af9d7a3926c6
+size 31327
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_socket_monitor.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_socket_monitor.3
new file mode 100644
index 00000000000000..2ec1de4978d194
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_socket_monitor.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:173c4fcff8079ebda6a999734b3e5bdad857931331de3a9d4abe2f8a5bf7c045
+size 9446
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_strerror.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_strerror.3
new file mode 100644
index 00000000000000..9ae3590ae43c3b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_strerror.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:255128a5fb9472e76fc610c9c0d316a37c6feaa1c2f7ccea57e6b2964485272f
+size 2389
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_unbind.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_unbind.3
new file mode 100644
index 00000000000000..938a947c749174
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_unbind.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:50e59c17fefb0f73294cebb06d7f6b4151c4d7c60b4fcae9be91d1450533e185
+size 3779
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_version.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_version.3
new file mode 100644
index 00000000000000..5318a340b378fb
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_version.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f10ebd5d90684ce9201fe4cf7fed31f956707b78475ca0086c77401e78e69b69
+size 2399
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_z85_decode.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_z85_decode.3
new file mode 100644
index 00000000000000..60a733007713f7
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_z85_decode.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4f7489f289e5b926c51ca3be3a5a72500b1d27d28a7731709633786456d5703b
+size 2341
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_z85_encode.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_z85_encode.3
new file mode 100644
index 00000000000000..b8011cd9ae85c1
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmq_z85_encode.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:06e8f16035f16ca0732fa4d71428bc4eff7ff7bf873e7baa2f5f202db0fa288e
+size 2581
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zmsg.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zmsg.3
new file mode 100644
index 00000000000000..b032b2b49c0269
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zmsg.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e7a85526bce10f9aac332153ae110705676ebf36f9899038c578133d1bda84bb
+size 17876
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zpoller.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zpoller.3
new file mode 100644
index 00000000000000..c0bf7970856a08
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zpoller.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7653f5408945692895edf25809890a6cd305d473aab961e345edf0b4212e6fcc
+size 7631
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zproc.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zproc.3
new file mode 100644
index 00000000000000..83667fb8476753
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zproc.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:11248a850e2a6aa6a9acc430a80f9b41320e1877a081465ec0e2bdc9078a21a4
+size 9035
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zproxy.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zproxy.3
new file mode 100644
index 00000000000000..0e5c9395e13009
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zproxy.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:abdbbd79bce126aef19ffa209be927b9cff03e29493005ac8b3bdee452c10834
+size 14076
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zrex.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zrex.3
new file mode 100644
index 00000000000000..e5b228f854cfc7
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zrex.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e1ba3f0c89103df19cc6b08a437070e8609468125a96c4c4421520531beb6f2a
+size 7195
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zsock.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zsock.3
new file mode 100644
index 00000000000000..160f62d23c19ff
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zsock.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:12971a8516ab8d9596dd8f6a109b6c15eb4916a82259f7a95bf7570f781534c4
+size 51574
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zstr.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zstr.3
new file mode 100644
index 00000000000000..2b3787f5231d22
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zstr.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9a541bb58e2b13666880141f47f20dca0ec7221ed4a55957d8bffdd44bb39908
+size 8214
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zsys.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zsys.3
new file mode 100644
index 00000000000000..1da2284e92b32a
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zsys.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:87af89b79fd92b36a1e0887194e2dce9cf32a8cb93166965fa32caa33f072eb0
+size 21228
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/ztimerset.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/ztimerset.3
new file mode 100644
index 00000000000000..222158f547d87f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/ztimerset.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:506fc86350e7c9dd292f5f83009dcd52edd79632eefaad30cc9cce3fee7c6c0e
+size 6276
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/ztrie.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/ztrie.3
new file mode 100644
index 00000000000000..f8321cbb77f004
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/ztrie.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:dfe8e0ac8fa75f6f1ea3be1f3a462bef24e76628cabedff5159a16fa98b0f77a
+size 12827
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man3/zuuid.3 b/phonelibs/zmq/aarch64-linux/share/man/man3/zuuid.3
new file mode 100644
index 00000000000000..74634cf5b9fac1
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man3/zuuid.3
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:62fa312bffea7e94b26665830b381b5a9147b9a6bab769f5783363cae6d36961
+size 5722
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/czmq.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/czmq.7
new file mode 100644
index 00000000000000..8311c7e1b668e3
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/czmq.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d8c1f3916d74e0be918b46bbe4f38a804a47c84449bdc1cebf92d554d6629b46
+size 28120
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq.7
new file mode 100644
index 00000000000000..2c3d12f21b07c0
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9b146c5a356c862c05b56e486b4bd618e99137fa02b2800d710546fafdaed3a3
+size 9729
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_curve.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_curve.7
new file mode 100644
index 00000000000000..89f3eef15a386d
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_curve.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:20bbf0db7915217090a926ebadb6fb630bcc134c99bf12bc58e3124eaf467dd8
+size 4241
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_inproc.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_inproc.7
new file mode 100644
index 00000000000000..22d5fad7ab3739
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_inproc.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:46d8b2c7a1dadc3ec2f6b868493cd2c37c1e907d16289dd203adc8bb2613fb36
+size 4178
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_ipc.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_ipc.7
new file mode 100644
index 00000000000000..b6b53c7833d9ac
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_ipc.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:040004d69f811768f4c7285b9212e8260cc5a1585bdd102e936f5804c81ab4f6
+size 5701
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_null.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_null.7
new file mode 100644
index 00000000000000..907b75e799d249
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_null.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c3bc3e2e9fe14d82132f4619ed064c7d8ef7caf76c72e5d903bb7d1e425e8c9a
+size 1714
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_pgm.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_pgm.7
new file mode 100644
index 00000000000000..0b76fe88e624c0
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_pgm.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3787cf65088455b66112d44318eb2da3138315b1e7b2d4f45d3598cee2f17ca1
+size 7808
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_plain.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_plain.7
new file mode 100644
index 00000000000000..391bfa34a748e6
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_plain.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:84bb1b5566d834cc85b72a9ca2d772a5f7335854c3563704094df71a9b542d59
+size 2136
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_tcp.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_tcp.7
new file mode 100644
index 00000000000000..5b53124ed3ffe9
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_tcp.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:00130d02b88f509bd2b1316b6d29647b5b9cfefb84130de40e28d82bb0ae153b
+size 5752
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_tipc.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_tipc.7
new file mode 100644
index 00000000000000..fa16f39d9728b4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_tipc.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3e984c09e14e553fb08134c636b606b45a397b501c2ce0a0273cc0914e526dca
+size 3573
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_udp.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_udp.7
new file mode 100644
index 00000000000000..51e9f1840da41f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_udp.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7ee895ca4af242c0e36684c4f2bed7fae7e97a7c7465c64699fa9c779dac58d2
+size 4395
diff --git a/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_vmci.7 b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_vmci.7
new file mode 100644
index 00000000000000..88110ee64c481f
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/man/man7/zmq_vmci.7
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ad102ce35f78e7d3b7e206d04b842aab660026b099f18bef3797e67605273532
+size 4619
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zactor.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zactor.api
new file mode 100644
index 00000000000000..974143b9eee59d
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zactor.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9826ce5f8f600ecbd903d3cebbfe20fb924185778dcde1fd61369dcb90ffa0a9
+size 2290
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zarmour.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zarmour.api
new file mode 100644
index 00000000000000..300176fe757007
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zarmour.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1aefc4d428c5020e956f8ff63874428ce13d832e395ee59919729a61b5c13683
+size 3362
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zcert.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zcert.api
new file mode 100644
index 00000000000000..a2800aae4afc5b
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zcert.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a4d53e54aa2b1d7a616f3f5b7aa8ff1db31ef9f630a6bb4520f593acf3e48ab4
+size 4083
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zcertstore.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zcertstore.api
new file mode 100644
index 00000000000000..2ad976a62e9358
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zcertstore.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:742c8702211602c4a889eca03f185f02520832a5291746767dfa87124563bab3
+size 2997
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zchunk.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zchunk.api
new file mode 100644
index 00000000000000..c3fbaac88ac2b2
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zchunk.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cfb19bf7d822d7b85ce076881c30ea515bfdc5c894c5d4044e8ddf519c0ec4ff
+size 6368
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zclock.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zclock.api
new file mode 100644
index 00000000000000..9f7774b4de2c76
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zclock.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:89af2ca114341e31005e4bf4fa0f13c4054a19fc741d31c4c2353ddf3b738e62
+size 1760
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zconfig.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zconfig.api
new file mode 100644
index 00000000000000..64c95ea4756a73
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zconfig.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e96de46830fe20e4e74ce50f3a38916923bc76c188e9730d9993aa7364bd3f16
+size 6661
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdigest.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdigest.api
new file mode 100644
index 00000000000000..f64a5b2fe84678
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdigest.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f19e2777648cfb9b935f8691725f38030ef28ac7a0291a849988627228255177
+size 1555
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdir.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdir.api
new file mode 100644
index 00000000000000..0c1fef19ef7ab2
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdir.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a66a1a3ad3d93b6db96e576238887f4143481cd11955bc0235e8433b36eb29a3
+size 4371
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdir_patch.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdir_patch.api
new file mode 100644
index 00000000000000..4bd4d54a0231b4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zdir_patch.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3e0298a4b893f1bc4c3540c3704250a2d5174f80c75dfe68bbacca5facfababa
+size 1791
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zfile.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zfile.api
new file mode 100644
index 00000000000000..7c5b898ebdef7c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zfile.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ab9915fded6de5d27f682ccca9673a67fcd203eeeb55fc0348eeda6aa3a42d89
+size 5405
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zframe.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zframe.api
new file mode 100644
index 00000000000000..cd06873f60c49c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zframe.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bdd244f4152b277e2587db422dd2b9008fa4926507f3afa7d3a9dd0c1bbe48c2
+size 5592
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zgossip_msg.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zgossip_msg.api
new file mode 100644
index 00000000000000..9906ad87ca2b7e
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zgossip_msg.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e03edfa8fad7b50acea5d96e148543fefcc58af7012386843c699611ab09d7a1
+size 3218
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zhash.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zhash.api
new file mode 100644
index 00000000000000..de5a02e9439e74
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zhash.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:50e5b4c36f175e09625e9ac7ce84b1ff8bda734764a9c054d3ab45d49614aee9
+size 7410
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zhashx.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zhashx.api
new file mode 100644
index 00000000000000..b01f9e622c3501
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zhashx.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:076ab11fa2d8b66b0a9054f5746af514a0e60e0d35cf967ecc2ffbb0e5e0622f
+size 12179
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ziflist.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ziflist.api
new file mode 100644
index 00000000000000..2cc14ee906a946
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ziflist.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:858d525bb64dd8bc3ce900f2863d91d2447226c7a9b7ef0fed8351fcc1b8bce7
+size 1724
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zlist.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zlist.api
new file mode 100644
index 00000000000000..dbdfd6183936d4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zlist.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b3d1fb52af53a77905a228390d94201e398494b237f66500346279145a1662bf
+size 6348
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zlistx.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zlistx.api
new file mode 100644
index 00000000000000..b4a10cd0ec3d27
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zlistx.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:151b3108fae69ee10b2961216c8a8fc27ae0037aede4e9cad0677c66bbb56efa
+size 9198
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zloop.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zloop.api
new file mode 100644
index 00000000000000..cc24737b529c16
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zloop.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:39e95b0d89c1635cc6c02a1bcdd704cfa76eaf56a14cb9e6ec1aab0bcbbbb1e1
+size 7721
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zmsg.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zmsg.api
new file mode 100644
index 00000000000000..024c0e6aed5b53
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zmsg.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:13b0e349b67636f2dfa314650e97e74db1228e7eaee1344c879c27ecd5eef2da
+size 9918
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zpoller.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zpoller.api
new file mode 100644
index 00000000000000..4f2520837de761
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zpoller.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6ea8ef73c9d9a5fc7f20e98091d07de3c88822a9aaba9e0edfd531b22375fb24
+size 3074
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zproc.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zproc.api
new file mode 100644
index 00000000000000..8e50197ccca26c
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zproc.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:eb7d75a6ada0fb318dfa2442a2f0f8c798443200cf4b873d3efd126202f19ec7
+size 6262
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zsock.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zsock.api
new file mode 100644
index 00000000000000..97c7aa8455bf08
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zsock.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:90c65feecc02b2ddbdfa7d7064b4ab35c82048a45e280c7bd8e47ce7cd2bd1d6
+size 18050
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zsock_option.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zsock_option.api
new file mode 100644
index 00000000000000..ec1c80e5f4d412
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zsock_option.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8816be9977843e6f1cba59210292121b523e242148818f9afd9edb7f12bc61b2
+size 24845
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zstr.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zstr.api
new file mode 100644
index 00000000000000..df8e5c933e0d50
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zstr.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:840d551c958cc009123952ecd41041f4badb1006d9844ebf818e75941264052a
+size 3973
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ztimerset.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ztimerset.api
new file mode 100644
index 00000000000000..6f0114529497f4
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ztimerset.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:57f73090875edd5348b97770f68a20380f909526b7f8de21f2486a5318c01162
+size 2467
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ztrie.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ztrie.api
new file mode 100644
index 00000000000000..88227b4c02602d
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/ztrie.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f3f3b3068847d7ed87d8caced3550b36ea703be1095ad46e5e4aebfdb1c97a48
+size 2877
diff --git a/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zuuid.api b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zuuid.api
new file mode 100644
index 00000000000000..87ca42083b6e70
--- /dev/null
+++ b/phonelibs/zmq/aarch64-linux/share/zproject/czmq/zuuid.api
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:890e831bf1651a34eb29ce484bb5520cd1c6a2631e5afbb3760799b2e757dccf
+size 2510
diff --git a/phonelibs/zmq/aarch64/include/czmq.h b/phonelibs/zmq/aarch64/include/czmq.h
new file mode 100644
index 00000000000000..10d64f81873b4e
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/czmq.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:12af7932bddbb54cf2c2b24ae837c307080daa3370b8bc6dd7321ba06fd7a5fc
+size 1110
diff --git a/phonelibs/zmq/aarch64/include/czmq_library.h b/phonelibs/zmq/aarch64/include/czmq_library.h
new file mode 100644
index 00000000000000..afd8bfc1de4ada
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/czmq_library.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:288309c96a99f4df9bd439b8a60d305b2375d1a39e9a9905f90ab4fdc8b24f5f
+size 6113
diff --git a/phonelibs/zmq/aarch64/include/czmq_prelude.h b/phonelibs/zmq/aarch64/include/czmq_prelude.h
new file mode 100644
index 00000000000000..ee430059f2a711
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/czmq_prelude.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6e32111326b91a16db1cd72af8520be7d1eda1f8427db67f3b6183523d1ea182
+size 18943
diff --git a/phonelibs/zmq/aarch64/include/zactor.h b/phonelibs/zmq/aarch64/include/zactor.h
new file mode 100644
index 00000000000000..b29ec9afe1b1ee
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zactor.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f5e5e9e2086688abc765e0c13d6621b7648d0a5fe41446af777f9f192fbaeb29
+size 2473
diff --git a/phonelibs/zmq/aarch64/include/zarmour.h b/phonelibs/zmq/aarch64/include/zarmour.h
new file mode 100644
index 00000000000000..44f6ba24fb4509
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zarmour.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f9696bd0aea94f596a6ad7083b72e7fc30c31b0da16d5731225a31d1c2c4ee11
+size 3644
diff --git a/phonelibs/zmq/aarch64/include/zauth.h b/phonelibs/zmq/aarch64/include/zauth.h
new file mode 100644
index 00000000000000..75fb8fd6c7697a
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zauth.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2638f40e6ffeb60ea1ba6224c2589779e0d734340aa3e08b4a2821b08c25a94c
+size 3612
diff --git a/phonelibs/zmq/aarch64/include/zauth_v2.h b/phonelibs/zmq/aarch64/include/zauth_v2.h
new file mode 100644
index 00000000000000..4af41414c24ee7
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zauth_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2674a57fc2593cb2ccdd8ab6e2e5776eb4ad648d503e769e6a8756c0bee104f1
+size 3449
diff --git a/phonelibs/zmq/aarch64/include/zbeacon.h b/phonelibs/zmq/aarch64/include/zbeacon.h
new file mode 100644
index 00000000000000..dd238d8abd15ac
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zbeacon.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c4212faea9f2a2f7ba343cc02987fd96deffe8e23dee35e2c0a088841abffecb
+size 2856
diff --git a/phonelibs/zmq/aarch64/include/zbeacon_v2.h b/phonelibs/zmq/aarch64/include/zbeacon_v2.h
new file mode 100644
index 00000000000000..65af279ea82630
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zbeacon_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6ac3a8725076e0c821b40a09989ab354d0961ad75174adcee86ffb3b9c705226
+size 2326
diff --git a/phonelibs/zmq/aarch64/include/zcert.h b/phonelibs/zmq/aarch64/include/zcert.h
new file mode 100644
index 00000000000000..6308f4cdc07bc4
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zcert.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4bf47e53573e20faacefe225463194ee6b3bb571cb122e56ddd2019537aacae0
+size 4811
diff --git a/phonelibs/zmq/aarch64/include/zcertstore.h b/phonelibs/zmq/aarch64/include/zcertstore.h
new file mode 100644
index 00000000000000..0e4b7c87ff1e32
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zcertstore.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e153358fddb6a9dca76a8f46ab0db6aa8b729e9728491454304dabf77d306a7d
+size 3993
diff --git a/phonelibs/zmq/aarch64/include/zchunk.h b/phonelibs/zmq/aarch64/include/zchunk.h
new file mode 100644
index 00000000000000..dc923ae56ac3d3
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zchunk.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c5391efa3017a3fd4d90b73f661e43f0b0664052520f4f983b38766376521d7b
+size 5899
diff --git a/phonelibs/zmq/aarch64/include/zclock.h b/phonelibs/zmq/aarch64/include/zclock.h
new file mode 100644
index 00000000000000..28846600750077
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zclock.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7f3f0c545553e4cef2115043f5ba58f5c856889c215fe123ed95d46dae14dfa5
+size 2465
diff --git a/phonelibs/zmq/aarch64/include/zconfig.h b/phonelibs/zmq/aarch64/include/zconfig.h
new file mode 100644
index 00000000000000..7e3dd189716b0f
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zconfig.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4faada45b4fc8316d139b0b18893582129fbcbdb79a03045b39f6871f63912a5
+size 6928
diff --git a/phonelibs/zmq/aarch64/include/zctx.h b/phonelibs/zmq/aarch64/include/zctx.h
new file mode 100644
index 00000000000000..e68fcbcb94675e
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zctx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f48cb2bc6175b27f0ac500b49acf9d519431c363972b3f4923b7695bff624730
+size 3520
diff --git a/phonelibs/zmq/aarch64/include/zdigest.h b/phonelibs/zmq/aarch64/include/zdigest.h
new file mode 100644
index 00000000000000..bce0ecf8292ffa
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zdigest.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:22a41bbe93e99cca59fe8d1617fb27b336cd2c4f2d094b4eea95f98e3470fce3
+size 2069
diff --git a/phonelibs/zmq/aarch64/include/zdir.h b/phonelibs/zmq/aarch64/include/zdir.h
new file mode 100644
index 00000000000000..663530347883c5
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zdir.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4ea8ae429fee870ac8c605fe28adf604d7dd22109360f7c089471ec9f07f754d
+size 6129
diff --git a/phonelibs/zmq/aarch64/include/zdir_patch.h b/phonelibs/zmq/aarch64/include/zdir_patch.h
new file mode 100644
index 00000000000000..1157d28dca4217
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zdir_patch.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bdf4336095870dba4e5fdb89a7867b26b61a879cf4c0631dab857ebbee79ff9f
+size 2422
diff --git a/phonelibs/zmq/aarch64/include/zfile.h b/phonelibs/zmq/aarch64/include/zfile.h
new file mode 100644
index 00000000000000..6c0b217987a14f
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zfile.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a66c39280771660524a50e359e2adc6f35df35a11d6cf7d922740e2d3b34e04a
+size 6250
diff --git a/phonelibs/zmq/aarch64/include/zframe.h b/phonelibs/zmq/aarch64/include/zframe.h
new file mode 100644
index 00000000000000..58a74b27c2559f
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zframe.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6f3b444f0b237c105a7aaef90ba2e09609e5d06a5a278c6cc5a6b8a1aa6c9752
+size 6538
diff --git a/phonelibs/zmq/aarch64/include/zgossip.h b/phonelibs/zmq/aarch64/include/zgossip.h
new file mode 100644
index 00000000000000..c49417587ddc3c
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zgossip.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:132f3c042ffc2a056405a6857a66ec6bfe40fad7edfc3229ef6b833407a0bfe3
+size 2964
diff --git a/phonelibs/zmq/aarch64/include/zhash.h b/phonelibs/zmq/aarch64/include/zhash.h
new file mode 100644
index 00000000000000..6450c9a9fa0741
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zhash.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ab662b94646bc2494e4c737c1ac00b9000badf2f487a16adfaeb6120a468d9d2
+size 8943
diff --git a/phonelibs/zmq/aarch64/include/zhashx.h b/phonelibs/zmq/aarch64/include/zhashx.h
new file mode 100644
index 00000000000000..0c01c1e9db2487
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zhashx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c569d9e5b882da3c1d1eb5587f37e015299414fc21933d5438fc29c24a037bd6
+size 13767
diff --git a/phonelibs/zmq/aarch64/include/ziflist.h b/phonelibs/zmq/aarch64/include/ziflist.h
new file mode 100644
index 00000000000000..0a01a19c621dc6
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/ziflist.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3df305f973face711a307384a310bbe3d74afbd06fc263e4fe78e6886244df73
+size 2256
diff --git a/phonelibs/zmq/aarch64/include/zlist.h b/phonelibs/zmq/aarch64/include/zlist.h
new file mode 100644
index 00000000000000..19376fb3d744c9
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zlist.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:23ca4ea43fe89ef066c42c0524b21bb2f3857bda386f8df8109f69cb25f13cc4
+size 6202
diff --git a/phonelibs/zmq/aarch64/include/zlistx.h b/phonelibs/zmq/aarch64/include/zlistx.h
new file mode 100644
index 00000000000000..df1ab07816da47
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zlistx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:382c7fa2cfdcb3efdf1631ba6ba1f97bb03297c102cf6e629c3db8519e946a0e
+size 8547
diff --git a/phonelibs/zmq/aarch64/include/zloop.h b/phonelibs/zmq/aarch64/include/zloop.h
new file mode 100644
index 00000000000000..f7835e89dd16a1
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zloop.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1c65b2148d5514638c2d30f0de3f0a29f334986142414bfb2548c20030ec1e46
+size 7460
diff --git a/phonelibs/zmq/aarch64/include/zmonitor.h b/phonelibs/zmq/aarch64/include/zmonitor.h
new file mode 100644
index 00000000000000..21c138037f9e9f
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zmonitor.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8c4004636f31648f98050e637daa231c70fcf4b64da326548b4f50dccba5ceb1
+size 1889
diff --git a/phonelibs/zmq/aarch64/include/zmonitor_v2.h b/phonelibs/zmq/aarch64/include/zmonitor_v2.h
new file mode 100644
index 00000000000000..a76fb49cfd7d19
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zmonitor_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f50c065b82825f6cdaecd67cc70743c8e9a31e09dc5dfea120afcac4987d8027
+size 1582
diff --git a/phonelibs/zmq/aarch64/include/zmq.h b/phonelibs/zmq/aarch64/include/zmq.h
new file mode 100644
index 00000000000000..0e65d39f491892
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zmq.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:033fd6f0e51b20d1d0d4667d4ddf9cfe0d389eafe65490436fe9a003d5e599a6
+size 22965
diff --git a/phonelibs/zmq/aarch64/include/zmq_utils.h b/phonelibs/zmq/aarch64/include/zmq_utils.h
new file mode 100644
index 00000000000000..947923e6dd9a62
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zmq_utils.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:926abbe8a8ab28df17746ca5bf60440b799b391be172c406e0628cdef3788909
+size 2316
diff --git a/phonelibs/zmq/aarch64/include/zmsg.h b/phonelibs/zmq/aarch64/include/zmsg.h
new file mode 100644
index 00000000000000..8224783105809d
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zmsg.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d723e0a1422461be75780f3801477f36cadb09b03e2f4a3e81ada72a9c7fa59c
+size 11698
diff --git a/phonelibs/zmq/aarch64/include/zmutex.h b/phonelibs/zmq/aarch64/include/zmutex.h
new file mode 100644
index 00000000000000..4485f62e45dcc7
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zmutex.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7678c6f6056ddfc4a58fddbb5fbd373755b7052fa704cce74a27aa7493aa75ca
+size 1394
diff --git a/phonelibs/zmq/aarch64/include/zpoller.h b/phonelibs/zmq/aarch64/include/zpoller.h
new file mode 100644
index 00000000000000..2e40b608d8a7a3
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zpoller.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:15b35fe5fbcff5e58701a934724f54d367bfc9ba1bd80da59d9ac4db45dfb93a
+size 3728
diff --git a/phonelibs/zmq/aarch64/include/zproc.h b/phonelibs/zmq/aarch64/include/zproc.h
new file mode 100644
index 00000000000000..a7df1e87a14c90
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zproc.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:20171a7b330c3142a51b9c58c07221c4e1076505b88dc52319c3e4c761698838
+size 8135
diff --git a/phonelibs/zmq/aarch64/include/zproxy.h b/phonelibs/zmq/aarch64/include/zproxy.h
new file mode 100644
index 00000000000000..04dd99d8031efa
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zproxy.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:61798dbd369cfefd3a90376818f628107bff9131d95cc8b444a924c28cb06115
+size 3889
diff --git a/phonelibs/zmq/aarch64/include/zproxy_v2.h b/phonelibs/zmq/aarch64/include/zproxy_v2.h
new file mode 100644
index 00000000000000..72a3a1d522df70
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zproxy_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:630b2d19cd98817c3ec2893f398466cc55b2a26e71e88b3a05dd940a681e93da
+size 1957
diff --git a/phonelibs/zmq/aarch64/include/zrex.h b/phonelibs/zmq/aarch64/include/zrex.h
new file mode 100644
index 00000000000000..48f2dd46765e07
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zrex.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5aa3120214f9fa79436f9b5ed4db050a5974d774dd99bd0e9bba13f70f04be6d
+size 2903
diff --git a/phonelibs/zmq/aarch64/include/zsock.h b/phonelibs/zmq/aarch64/include/zsock.h
new file mode 100644
index 00000000000000..c0565456f7b5d3
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zsock.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6d821c68a69e67bc787d692507c024f1227670e84a4a51bde821ddfa856f4321
+size 36671
diff --git a/phonelibs/zmq/aarch64/include/zsocket.h b/phonelibs/zmq/aarch64/include/zsocket.h
new file mode 100644
index 00000000000000..7e1c8997cb6fd9
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zsocket.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:47bc88aaba1b2672d38df07379ba23b79621ac3f6c29643f764171879588cda7
+size 3939
diff --git a/phonelibs/zmq/aarch64/include/zsockopt.h b/phonelibs/zmq/aarch64/include/zsockopt.h
new file mode 100644
index 00000000000000..abe090ca4e42fe
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zsockopt.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cf59f6989aa5437be9aee8b9577bcc0e784964e6013320767870898dcdf198d8
+size 14034
diff --git a/phonelibs/zmq/aarch64/include/zstr.h b/phonelibs/zmq/aarch64/include/zstr.h
new file mode 100644
index 00000000000000..b294826a000bb0
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zstr.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5c48b4b887c6bc47232c274eeef38d8e7956735e0a13aed7ac824df59583c0c6
+size 4710
diff --git a/phonelibs/zmq/aarch64/include/zsys.h b/phonelibs/zmq/aarch64/include/zsys.h
new file mode 100644
index 00000000000000..944d89a777f6e0
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zsys.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b0fb3776e0587966abb11f743aeea465ce7a25d50141b256c90b61b19c074770
+size 15888
diff --git a/phonelibs/zmq/aarch64/include/zthread.h b/phonelibs/zmq/aarch64/include/zthread.h
new file mode 100644
index 00000000000000..c917ec84eaed3f
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zthread.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:11d2ac5dd71c3babf3d7a50eae30ea8197576bfdffc91148217689992f60a74e
+size 1624
diff --git a/phonelibs/zmq/aarch64/include/ztimerset.h b/phonelibs/zmq/aarch64/include/ztimerset.h
new file mode 100644
index 00000000000000..4621e8f084b1b4
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/ztimerset.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:09649e6b235a6b2af50eb7e7644c38fd5132d16e4b63351affd7adf5009f06ad
+size 3551
diff --git a/phonelibs/zmq/aarch64/include/ztrie.h b/phonelibs/zmq/aarch64/include/ztrie.h
new file mode 100644
index 00000000000000..7f5f61c27bc9a6
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/ztrie.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:89dc6a1b5e09267704dc07ed986fb82b5057e51a4e7f0bf801cc204dedf9fb4e
+size 4475
diff --git a/phonelibs/zmq/aarch64/include/zuuid.h b/phonelibs/zmq/aarch64/include/zuuid.h
new file mode 100644
index 00000000000000..4676899834a87c
--- /dev/null
+++ b/phonelibs/zmq/aarch64/include/zuuid.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6de67e7d53ebbffefe2c330bded67425df97d8bb5d79717d0227e3b6fb1899f9
+size 2790
diff --git a/phonelibs/zmq/aarch64/lib/libczmq.a b/phonelibs/zmq/aarch64/lib/libczmq.a
new file mode 100644
index 00000000000000..55cd0425abde09
--- /dev/null
+++ b/phonelibs/zmq/aarch64/lib/libczmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9618198e65b31e6816bc0aa7f72a22de06d402e0554e3e0d26ddf267fa18a5c8
+size 1344552
diff --git a/phonelibs/zmq/aarch64/lib/libczmq.la b/phonelibs/zmq/aarch64/lib/libczmq.la
new file mode 100755
index 00000000000000..355cd5ffe24e6c
--- /dev/null
+++ b/phonelibs/zmq/aarch64/lib/libczmq.la
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:fced2688e3eba856e6419c392355c643520d6b61c0319a3671105709c73fe8b4
+size 1355
diff --git a/phonelibs/zmq/aarch64/lib/libczmq.so b/phonelibs/zmq/aarch64/lib/libczmq.so
new file mode 100755
index 00000000000000..7c20ca1856d08a
--- /dev/null
+++ b/phonelibs/zmq/aarch64/lib/libczmq.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b7804a57fad15a6464fe57d593f9922ff642bb4571b36e58195b0a03d68582d4
+size 688384
diff --git a/phonelibs/zmq/aarch64/lib/libzmq.a b/phonelibs/zmq/aarch64/lib/libzmq.a
new file mode 100644
index 00000000000000..a32cab1701330e
--- /dev/null
+++ b/phonelibs/zmq/aarch64/lib/libzmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d267f512e7c5e2247ce702a8cc7cb20cc08e2ffbeaa2495cb4915f7a771dfd4a
+size 5113020
diff --git a/phonelibs/zmq/aarch64/lib/libzmq.la b/phonelibs/zmq/aarch64/lib/libzmq.la
new file mode 100755
index 00000000000000..52f6129018990f
--- /dev/null
+++ b/phonelibs/zmq/aarch64/lib/libzmq.la
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b69dbd5282f4d3951c00e92fdc58a6635f0ae5b84649a1dc7dd9a0f2798287a2
+size 1104
diff --git a/phonelibs/zmq/aarch64/lib/libzmq.so b/phonelibs/zmq/aarch64/lib/libzmq.so
new file mode 100755
index 00000000000000..18e2f3fb9f2248
--- /dev/null
+++ b/phonelibs/zmq/aarch64/lib/libzmq.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:08cc8a870269dc18f1f6351a88895d0d8479229c549b07752009e299a53911ac
+size 1351000
diff --git a/phonelibs/zmq/arm/include/czmq.h b/phonelibs/zmq/arm/include/czmq.h
new file mode 100644
index 00000000000000..10d64f81873b4e
--- /dev/null
+++ b/phonelibs/zmq/arm/include/czmq.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:12af7932bddbb54cf2c2b24ae837c307080daa3370b8bc6dd7321ba06fd7a5fc
+size 1110
diff --git a/phonelibs/zmq/arm/include/czmq_library.h b/phonelibs/zmq/arm/include/czmq_library.h
new file mode 100644
index 00000000000000..afd8bfc1de4ada
--- /dev/null
+++ b/phonelibs/zmq/arm/include/czmq_library.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:288309c96a99f4df9bd439b8a60d305b2375d1a39e9a9905f90ab4fdc8b24f5f
+size 6113
diff --git a/phonelibs/zmq/arm/include/czmq_prelude.h b/phonelibs/zmq/arm/include/czmq_prelude.h
new file mode 100644
index 00000000000000..ee430059f2a711
--- /dev/null
+++ b/phonelibs/zmq/arm/include/czmq_prelude.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6e32111326b91a16db1cd72af8520be7d1eda1f8427db67f3b6183523d1ea182
+size 18943
diff --git a/phonelibs/zmq/arm/include/zactor.h b/phonelibs/zmq/arm/include/zactor.h
new file mode 100644
index 00000000000000..b29ec9afe1b1ee
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zactor.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f5e5e9e2086688abc765e0c13d6621b7648d0a5fe41446af777f9f192fbaeb29
+size 2473
diff --git a/phonelibs/zmq/arm/include/zarmour.h b/phonelibs/zmq/arm/include/zarmour.h
new file mode 100644
index 00000000000000..44f6ba24fb4509
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zarmour.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f9696bd0aea94f596a6ad7083b72e7fc30c31b0da16d5731225a31d1c2c4ee11
+size 3644
diff --git a/phonelibs/zmq/arm/include/zauth.h b/phonelibs/zmq/arm/include/zauth.h
new file mode 100644
index 00000000000000..75fb8fd6c7697a
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zauth.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2638f40e6ffeb60ea1ba6224c2589779e0d734340aa3e08b4a2821b08c25a94c
+size 3612
diff --git a/phonelibs/zmq/arm/include/zauth_v2.h b/phonelibs/zmq/arm/include/zauth_v2.h
new file mode 100644
index 00000000000000..4af41414c24ee7
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zauth_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2674a57fc2593cb2ccdd8ab6e2e5776eb4ad648d503e769e6a8756c0bee104f1
+size 3449
diff --git a/phonelibs/zmq/arm/include/zbeacon.h b/phonelibs/zmq/arm/include/zbeacon.h
new file mode 100644
index 00000000000000..dd238d8abd15ac
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zbeacon.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c4212faea9f2a2f7ba343cc02987fd96deffe8e23dee35e2c0a088841abffecb
+size 2856
diff --git a/phonelibs/zmq/arm/include/zbeacon_v2.h b/phonelibs/zmq/arm/include/zbeacon_v2.h
new file mode 100644
index 00000000000000..65af279ea82630
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zbeacon_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6ac3a8725076e0c821b40a09989ab354d0961ad75174adcee86ffb3b9c705226
+size 2326
diff --git a/phonelibs/zmq/arm/include/zcert.h b/phonelibs/zmq/arm/include/zcert.h
new file mode 100644
index 00000000000000..6308f4cdc07bc4
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zcert.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4bf47e53573e20faacefe225463194ee6b3bb571cb122e56ddd2019537aacae0
+size 4811
diff --git a/phonelibs/zmq/arm/include/zcertstore.h b/phonelibs/zmq/arm/include/zcertstore.h
new file mode 100644
index 00000000000000..0e4b7c87ff1e32
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zcertstore.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e153358fddb6a9dca76a8f46ab0db6aa8b729e9728491454304dabf77d306a7d
+size 3993
diff --git a/phonelibs/zmq/arm/include/zchunk.h b/phonelibs/zmq/arm/include/zchunk.h
new file mode 100644
index 00000000000000..dc923ae56ac3d3
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zchunk.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c5391efa3017a3fd4d90b73f661e43f0b0664052520f4f983b38766376521d7b
+size 5899
diff --git a/phonelibs/zmq/arm/include/zclock.h b/phonelibs/zmq/arm/include/zclock.h
new file mode 100644
index 00000000000000..28846600750077
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zclock.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7f3f0c545553e4cef2115043f5ba58f5c856889c215fe123ed95d46dae14dfa5
+size 2465
diff --git a/phonelibs/zmq/arm/include/zconfig.h b/phonelibs/zmq/arm/include/zconfig.h
new file mode 100644
index 00000000000000..7e3dd189716b0f
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zconfig.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4faada45b4fc8316d139b0b18893582129fbcbdb79a03045b39f6871f63912a5
+size 6928
diff --git a/phonelibs/zmq/arm/include/zctx.h b/phonelibs/zmq/arm/include/zctx.h
new file mode 100644
index 00000000000000..e68fcbcb94675e
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zctx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f48cb2bc6175b27f0ac500b49acf9d519431c363972b3f4923b7695bff624730
+size 3520
diff --git a/phonelibs/zmq/arm/include/zdigest.h b/phonelibs/zmq/arm/include/zdigest.h
new file mode 100644
index 00000000000000..bce0ecf8292ffa
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zdigest.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:22a41bbe93e99cca59fe8d1617fb27b336cd2c4f2d094b4eea95f98e3470fce3
+size 2069
diff --git a/phonelibs/zmq/arm/include/zdir.h b/phonelibs/zmq/arm/include/zdir.h
new file mode 100644
index 00000000000000..663530347883c5
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zdir.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4ea8ae429fee870ac8c605fe28adf604d7dd22109360f7c089471ec9f07f754d
+size 6129
diff --git a/phonelibs/zmq/arm/include/zdir_patch.h b/phonelibs/zmq/arm/include/zdir_patch.h
new file mode 100644
index 00000000000000..1157d28dca4217
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zdir_patch.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bdf4336095870dba4e5fdb89a7867b26b61a879cf4c0631dab857ebbee79ff9f
+size 2422
diff --git a/phonelibs/zmq/arm/include/zfile.h b/phonelibs/zmq/arm/include/zfile.h
new file mode 100644
index 00000000000000..6c0b217987a14f
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zfile.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a66c39280771660524a50e359e2adc6f35df35a11d6cf7d922740e2d3b34e04a
+size 6250
diff --git a/phonelibs/zmq/arm/include/zframe.h b/phonelibs/zmq/arm/include/zframe.h
new file mode 100644
index 00000000000000..58a74b27c2559f
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zframe.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6f3b444f0b237c105a7aaef90ba2e09609e5d06a5a278c6cc5a6b8a1aa6c9752
+size 6538
diff --git a/phonelibs/zmq/arm/include/zgossip.h b/phonelibs/zmq/arm/include/zgossip.h
new file mode 100644
index 00000000000000..c49417587ddc3c
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zgossip.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:132f3c042ffc2a056405a6857a66ec6bfe40fad7edfc3229ef6b833407a0bfe3
+size 2964
diff --git a/phonelibs/zmq/arm/include/zhash.h b/phonelibs/zmq/arm/include/zhash.h
new file mode 100644
index 00000000000000..6450c9a9fa0741
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zhash.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ab662b94646bc2494e4c737c1ac00b9000badf2f487a16adfaeb6120a468d9d2
+size 8943
diff --git a/phonelibs/zmq/arm/include/zhashx.h b/phonelibs/zmq/arm/include/zhashx.h
new file mode 100644
index 00000000000000..0c01c1e9db2487
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zhashx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c569d9e5b882da3c1d1eb5587f37e015299414fc21933d5438fc29c24a037bd6
+size 13767
diff --git a/phonelibs/zmq/arm/include/ziflist.h b/phonelibs/zmq/arm/include/ziflist.h
new file mode 100644
index 00000000000000..0a01a19c621dc6
--- /dev/null
+++ b/phonelibs/zmq/arm/include/ziflist.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3df305f973face711a307384a310bbe3d74afbd06fc263e4fe78e6886244df73
+size 2256
diff --git a/phonelibs/zmq/arm/include/zlist.h b/phonelibs/zmq/arm/include/zlist.h
new file mode 100644
index 00000000000000..19376fb3d744c9
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zlist.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:23ca4ea43fe89ef066c42c0524b21bb2f3857bda386f8df8109f69cb25f13cc4
+size 6202
diff --git a/phonelibs/zmq/arm/include/zlistx.h b/phonelibs/zmq/arm/include/zlistx.h
new file mode 100644
index 00000000000000..df1ab07816da47
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zlistx.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:382c7fa2cfdcb3efdf1631ba6ba1f97bb03297c102cf6e629c3db8519e946a0e
+size 8547
diff --git a/phonelibs/zmq/arm/include/zloop.h b/phonelibs/zmq/arm/include/zloop.h
new file mode 100644
index 00000000000000..f7835e89dd16a1
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zloop.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1c65b2148d5514638c2d30f0de3f0a29f334986142414bfb2548c20030ec1e46
+size 7460
diff --git a/phonelibs/zmq/arm/include/zmonitor.h b/phonelibs/zmq/arm/include/zmonitor.h
new file mode 100644
index 00000000000000..21c138037f9e9f
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zmonitor.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8c4004636f31648f98050e637daa231c70fcf4b64da326548b4f50dccba5ceb1
+size 1889
diff --git a/phonelibs/zmq/arm/include/zmonitor_v2.h b/phonelibs/zmq/arm/include/zmonitor_v2.h
new file mode 100644
index 00000000000000..a76fb49cfd7d19
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zmonitor_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f50c065b82825f6cdaecd67cc70743c8e9a31e09dc5dfea120afcac4987d8027
+size 1582
diff --git a/phonelibs/zmq/arm/include/zmq.h b/phonelibs/zmq/arm/include/zmq.h
new file mode 100644
index 00000000000000..0e65d39f491892
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zmq.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:033fd6f0e51b20d1d0d4667d4ddf9cfe0d389eafe65490436fe9a003d5e599a6
+size 22965
diff --git a/phonelibs/zmq/arm/include/zmq_utils.h b/phonelibs/zmq/arm/include/zmq_utils.h
new file mode 100644
index 00000000000000..947923e6dd9a62
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zmq_utils.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:926abbe8a8ab28df17746ca5bf60440b799b391be172c406e0628cdef3788909
+size 2316
diff --git a/phonelibs/zmq/arm/include/zmsg.h b/phonelibs/zmq/arm/include/zmsg.h
new file mode 100644
index 00000000000000..8224783105809d
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zmsg.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d723e0a1422461be75780f3801477f36cadb09b03e2f4a3e81ada72a9c7fa59c
+size 11698
diff --git a/phonelibs/zmq/arm/include/zmutex.h b/phonelibs/zmq/arm/include/zmutex.h
new file mode 100644
index 00000000000000..4485f62e45dcc7
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zmutex.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7678c6f6056ddfc4a58fddbb5fbd373755b7052fa704cce74a27aa7493aa75ca
+size 1394
diff --git a/phonelibs/zmq/arm/include/zpoller.h b/phonelibs/zmq/arm/include/zpoller.h
new file mode 100644
index 00000000000000..2e40b608d8a7a3
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zpoller.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:15b35fe5fbcff5e58701a934724f54d367bfc9ba1bd80da59d9ac4db45dfb93a
+size 3728
diff --git a/phonelibs/zmq/arm/include/zproc.h b/phonelibs/zmq/arm/include/zproc.h
new file mode 100644
index 00000000000000..a7df1e87a14c90
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zproc.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:20171a7b330c3142a51b9c58c07221c4e1076505b88dc52319c3e4c761698838
+size 8135
diff --git a/phonelibs/zmq/arm/include/zproxy.h b/phonelibs/zmq/arm/include/zproxy.h
new file mode 100644
index 00000000000000..04dd99d8031efa
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zproxy.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:61798dbd369cfefd3a90376818f628107bff9131d95cc8b444a924c28cb06115
+size 3889
diff --git a/phonelibs/zmq/arm/include/zproxy_v2.h b/phonelibs/zmq/arm/include/zproxy_v2.h
new file mode 100644
index 00000000000000..72a3a1d522df70
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zproxy_v2.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:630b2d19cd98817c3ec2893f398466cc55b2a26e71e88b3a05dd940a681e93da
+size 1957
diff --git a/phonelibs/zmq/arm/include/zrex.h b/phonelibs/zmq/arm/include/zrex.h
new file mode 100644
index 00000000000000..48f2dd46765e07
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zrex.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5aa3120214f9fa79436f9b5ed4db050a5974d774dd99bd0e9bba13f70f04be6d
+size 2903
diff --git a/phonelibs/zmq/arm/include/zsock.h b/phonelibs/zmq/arm/include/zsock.h
new file mode 100644
index 00000000000000..c0565456f7b5d3
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zsock.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6d821c68a69e67bc787d692507c024f1227670e84a4a51bde821ddfa856f4321
+size 36671
diff --git a/phonelibs/zmq/arm/include/zsocket.h b/phonelibs/zmq/arm/include/zsocket.h
new file mode 100644
index 00000000000000..7e1c8997cb6fd9
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zsocket.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:47bc88aaba1b2672d38df07379ba23b79621ac3f6c29643f764171879588cda7
+size 3939
diff --git a/phonelibs/zmq/arm/include/zsockopt.h b/phonelibs/zmq/arm/include/zsockopt.h
new file mode 100644
index 00000000000000..abe090ca4e42fe
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zsockopt.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cf59f6989aa5437be9aee8b9577bcc0e784964e6013320767870898dcdf198d8
+size 14034
diff --git a/phonelibs/zmq/arm/include/zstr.h b/phonelibs/zmq/arm/include/zstr.h
new file mode 100644
index 00000000000000..b294826a000bb0
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zstr.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5c48b4b887c6bc47232c274eeef38d8e7956735e0a13aed7ac824df59583c0c6
+size 4710
diff --git a/phonelibs/zmq/arm/include/zsys.h b/phonelibs/zmq/arm/include/zsys.h
new file mode 100644
index 00000000000000..944d89a777f6e0
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zsys.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b0fb3776e0587966abb11f743aeea465ce7a25d50141b256c90b61b19c074770
+size 15888
diff --git a/phonelibs/zmq/arm/include/zthread.h b/phonelibs/zmq/arm/include/zthread.h
new file mode 100644
index 00000000000000..c917ec84eaed3f
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zthread.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:11d2ac5dd71c3babf3d7a50eae30ea8197576bfdffc91148217689992f60a74e
+size 1624
diff --git a/phonelibs/zmq/arm/include/ztimerset.h b/phonelibs/zmq/arm/include/ztimerset.h
new file mode 100644
index 00000000000000..4621e8f084b1b4
--- /dev/null
+++ b/phonelibs/zmq/arm/include/ztimerset.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:09649e6b235a6b2af50eb7e7644c38fd5132d16e4b63351affd7adf5009f06ad
+size 3551
diff --git a/phonelibs/zmq/arm/include/ztrie.h b/phonelibs/zmq/arm/include/ztrie.h
new file mode 100644
index 00000000000000..7f5f61c27bc9a6
--- /dev/null
+++ b/phonelibs/zmq/arm/include/ztrie.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:89dc6a1b5e09267704dc07ed986fb82b5057e51a4e7f0bf801cc204dedf9fb4e
+size 4475
diff --git a/phonelibs/zmq/arm/include/zuuid.h b/phonelibs/zmq/arm/include/zuuid.h
new file mode 100644
index 00000000000000..4676899834a87c
--- /dev/null
+++ b/phonelibs/zmq/arm/include/zuuid.h
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6de67e7d53ebbffefe2c330bded67425df97d8bb5d79717d0227e3b6fb1899f9
+size 2790
diff --git a/phonelibs/zmq/arm/lib/libczmq.a b/phonelibs/zmq/arm/lib/libczmq.a
new file mode 100644
index 00000000000000..e14d1d6082b0ca
--- /dev/null
+++ b/phonelibs/zmq/arm/lib/libczmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9f23608f1521e443acb64bda0cb40a4da2405bed2fa29d8147c1e4c41e3037ec
+size 865728
diff --git a/phonelibs/zmq/arm/lib/libczmq.so b/phonelibs/zmq/arm/lib/libczmq.so
new file mode 100755
index 00000000000000..dc17f719c39876
--- /dev/null
+++ b/phonelibs/zmq/arm/lib/libczmq.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:923453f14924642719631db7bcd2713c5ad9fe9d7d877b6caf12a2b5f7ad89c4
+size 707900
diff --git a/phonelibs/zmq/arm/lib/libzmq.a b/phonelibs/zmq/arm/lib/libzmq.a
new file mode 100644
index 00000000000000..247b33aa4fc906
--- /dev/null
+++ b/phonelibs/zmq/arm/lib/libzmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8d533d845bc5ad13a1649ae96be1eff98f2d9ddfe586cd3e05eeb088680bf592
+size 5617928
diff --git a/phonelibs/zmq/arm/lib/libzmq.so b/phonelibs/zmq/arm/lib/libzmq.so
new file mode 100755
index 00000000000000..d344f0f8390d9f
--- /dev/null
+++ b/phonelibs/zmq/arm/lib/libzmq.so
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2a97974f1f1d6df5cdbbccd4308209cc03d78e5104b26b18fbe822c33c7de10f
+size 1268548
diff --git a/phonelibs/zmq/build.sh b/phonelibs/zmq/build.sh
new file mode 100755
index 00000000000000..b0effe6358d2da
--- /dev/null
+++ b/phonelibs/zmq/build.sh
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2c521234ebfde5b82521ce8e45b12242ec6b7a0b2fd4fe0414da77ffd528817e
+size 2199
diff --git a/phonelibs/zmq/build_aarch64.patch b/phonelibs/zmq/build_aarch64.patch
new file mode 100644
index 00000000000000..c1432817108666
--- /dev/null
+++ b/phonelibs/zmq/build_aarch64.patch
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:98644997824031aa9c80578ca644367d08960205a4186319fcad1008c95117a8
+size 881
diff --git a/phonelibs/zmq/build_linux.txt b/phonelibs/zmq/build_linux.txt
new file mode 100644
index 00000000000000..9cc8223a4bf79c
--- /dev/null
+++ b/phonelibs/zmq/build_linux.txt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:aa1eb0c0062676dd1a2234dbb66519d315a79d88ec2cd169ee78fe7bd10f6297
+size 178
diff --git a/phonelibs/zmq/mac/lib/libczmq.a b/phonelibs/zmq/mac/lib/libczmq.a
new file mode 100644
index 00000000000000..e90aabc4e7c9fb
--- /dev/null
+++ b/phonelibs/zmq/mac/lib/libczmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:824c6e80b2d9ba516ed8decbde32d1efc3af9d7aa76b17cdadafd88fc57d8185
+size 628352
diff --git a/phonelibs/zmq/mac/lib/libczmq.dylib b/phonelibs/zmq/mac/lib/libczmq.dylib
new file mode 100644
index 00000000000000..a1edde18b7c4fc
--- /dev/null
+++ b/phonelibs/zmq/mac/lib/libczmq.dylib
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bbbe4404c8e722f3510f6b93d13a9c9eee5d580d46adf8596b03cb937514f695
+size 353580
diff --git a/phonelibs/zmq/mac/lib/libzmq.a b/phonelibs/zmq/mac/lib/libzmq.a
new file mode 100644
index 00000000000000..75702bd0478813
--- /dev/null
+++ b/phonelibs/zmq/mac/lib/libzmq.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:96afefde9b258124554282860d64da173a032386fdfa1ffc4e6399c6adcc3a24
+size 1263200
diff --git a/phonelibs/zmq/mac/lib/libzmq.dylib b/phonelibs/zmq/mac/lib/libzmq.dylib
new file mode 100755
index 00000000000000..3370e0ec83f644
--- /dev/null
+++ b/phonelibs/zmq/mac/lib/libzmq.dylib
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e706a9d0acf8fcedf2ff66dbcaa267f819651c712bc87559bd0a9c1d0b1dd554
+size 621868
diff --git a/requirements_openpilot.txt b/requirements_openpilot.txt
index b623e2a25e2e11..2e892560fffb6d 100644
--- a/requirements_openpilot.txt
+++ b/requirements_openpilot.txt
@@ -1,20 +1,66 @@
+# This are the packages installed on the EON
+-e git+https://github.com/commaai/le_python.git@5eef8f5be5929d33973e1b10e686fa0cdcd6792f#egg=Logentries
+-e git+https://github.com/commaai/python-overpy.git@f86529af402d4642e1faeb146671c40284007323#egg=overpy
Cython==0.27.3
+Flask==1.0.2
+#PyGObject==3.28.2 This is installed on the EON, but requires a ton of dependencies to install
+PyYAML==3.12
+appdirs==1.4.0
+atomicwrites==1.1.5
+attrs==16.0.0
bitstring==3.1.5
+capnpy==0.4.2
+certifi==2016.8.31
+cffi==1.11.5
+contextlib2==0.5.4
+crc16==0.1.1
+crcmod==1.7
+cryptography==1.4
+cycler==0.10.0
+decorator==4.0.10
+docopt==0.6.2
+enum34==1.1.6
+evdev==0.6.1
fastcluster==1.1.20
+filterpy==1.2.4
+ipaddress==1.0.16
libusb1==1.5.0
+lmdb==0.92
+mpmath==1.0.0
+nose==1.3.7
+numpy==1.11.1
+pause==0.1.2
+py==1.4.31
+pyOpenSSL==16.0.0
+pyasn1-modules==0.0.8
+pyasn1==0.1.9
pycapnp==0.6.3
+pycparser==2.18
+pycrypto==2.6.1
+pyflakes==1.6.0
+pyopencl==2016.1
+pyparsing==2.1.10
+#pypcap==1.1.5 needs extra dependencies and is not used
+pyproj==1.9.5.1
+pypytools==0.4.3
+pyserial==3.1.1
+pytest==2.9.2
+python-dateutil==2.6.0
+pytools==2016.2.1
+pytz==2016.10
+pyyaml==3.12
pyzmq==15.4.0
raven==5.23.0
-requests==2.20.0
+recordclass==0.4.1
+requests==2.10.0
+scipy==0.19.1
+service-identity==16.0.0
setproctitle==1.1.10
simplejson==3.8.2
-pyyaml==3.12
-cffi==1.11.5
-enum34==1.1.6
-sympy==1.1.1
-filterpy==1.2.4
+six==1.10.0
+smbus-cffi==0.5.1
smbus2==0.2.0
-pyflakes==1.6.0
--e git+https://github.com/commaai/le_python.git@5eef8f5be5929d33973e1b10e686fa0cdcd6792f#egg=Logentries
--e git+https://github.com/commaai/python-overpy.git@f86529af402d4642e1faeb146671c40284007323#egg=overpy
-Flask==1.0.2
+sympy==1.1.1
+tqdm==4.23.1
+ujson==1.35
+v4l2==0.2
diff --git a/selfdrive/assets/img_map.png b/selfdrive/assets/img_map.png
new file mode 100644
index 00000000000000..a8646491d721e8
--- /dev/null
+++ b/selfdrive/assets/img_map.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4a197665ae2a7fc05109903474d513379711f7b7f555c4148ca99d589c95baf7
+size 31990
diff --git a/selfdrive/assets/img_trafficSign_turn.png b/selfdrive/assets/img_trafficSign_turn.png
new file mode 100644
index 00000000000000..0e5ba1da92f513
--- /dev/null
+++ b/selfdrive/assets/img_trafficSign_turn.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ffef2b735b06c547826f1717a860c9361d0c1d59ea53c5fc06339613ffc7d01a
+size 25497
diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc
index aae2b665aec1bb..74b1f4c5de9616 100644
--- a/selfdrive/boardd/boardd.cc
+++ b/selfdrive/boardd/boardd.cc
@@ -41,6 +41,7 @@
#define SAFETY_CADILLAC 6
#define SAFETY_HYUNDAI 7
#define SAFETY_TESLA 8
+#define SAFETY_CHRYSLER 9
#define SAFETY_TOYOTA_IPAS 0x1335
#define SAFETY_TOYOTA_NOLIMITS 0x1336
#define SAFETY_ALLOUTPUT 0x1337
@@ -120,6 +121,9 @@ void *safety_setter_thread(void *s) {
case (int)cereal::CarParams::SafetyModels::HYUNDAI:
safety_setting = SAFETY_HYUNDAI;
break;
+ case (int)cereal::CarParams::SafetyModels::CHRYSLER:
+ safety_setting = SAFETY_CHRYSLER;
+ break;
default:
LOGE("unknown safety model: %d", safety_model);
}
@@ -420,6 +424,14 @@ void *can_send_thread(void *crap) {
zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, "", 0);
zmq_connect(subscriber, "tcp://127.0.0.1:8017");
+ // drain sendcan to delete any stale messages from previous runs
+ zmq_msg_t msg;
+ zmq_msg_init(&msg);
+ int err = 0;
+ while(err >= 0) {
+ err = zmq_msg_recv(&msg, subscriber, ZMQ_DONTWAIT);
+ }
+
// run as fast as messages come in
while (!do_exit) {
can_send(subscriber);
diff --git a/selfdrive/boardd/boardd.py b/selfdrive/boardd/boardd.py
index 1e7b233ddda491..fb045bb3aafdc2 100755
--- a/selfdrive/boardd/boardd.py
+++ b/selfdrive/boardd/boardd.py
@@ -1,5 +1,8 @@
#!/usr/bin/env python
+# This file is not used by OpenPilot. Only boardd.cc is used.
+# The python version is slower, but has more options for development.
+
# TODO: merge the extra functionalities of this file (like MOCK) in boardd.c and
# delete this python version of boardd
@@ -23,6 +26,7 @@
SAFETY_NOOUTPUT = 0
SAFETY_HONDA = 1
SAFETY_TOYOTA = 2
+SAFETY_CHRYSLER = 9
SAFETY_TOYOTA_NOLIMITS = 0x1336
SAFETY_ALLOUTPUT = 0x1337
@@ -163,6 +167,9 @@ def boardd_loop(rate=200):
# *** subscribes to can send
sendcan = messaging.sub_sock(context, service_list['sendcan'].port)
+ # drain sendcan to delete any stale messages from previous runs
+ messaging.drain_sock(sendcan)
+
while 1:
# health packet @ 1hz
if (rk.frame%rate) == 0:
@@ -174,6 +181,7 @@ def boardd_loop(rate=200):
msg.health.voltage = health['voltage']
msg.health.current = health['current']
msg.health.started = health['started']
+ msg.health.controlsAllowed = True
health_sock.send(msg.to_bytes())
@@ -205,6 +213,9 @@ def boardd_proxy_loop(rate=200, address="192.168.2.251"):
# *** publishes to can send
sendcan = messaging.pub_sock(context, service_list['sendcan'].port)
+ # drain sendcan to delete any stale messages from previous runs
+ messaging.drain_sock(sendcan)
+
while 1:
# recv @ 100hz
can_msgs = can_recv()
diff --git a/selfdrive/can/packer.cc b/selfdrive/can/packer.cc
index 986de6b1172154..17171f15503048 100644
--- a/selfdrive/can/packer.cc
+++ b/selfdrive/can/packer.cc
@@ -100,7 +100,7 @@ namespace {
unsigned int chksm = toyota_checksum(address, ret, message_lookup[address].size);
ret = set_value(ret, sig, chksm);
} else {
- WARN("CHECKSUM signal type not valid\n");
+ //WARN("CHECKSUM signal type not valid\n");
}
}
diff --git a/selfdrive/can/parser.cc b/selfdrive/can/parser.cc
index 4a82d9a022f36f..7bb4ef26f76a86 100644
--- a/selfdrive/can/parser.cc
+++ b/selfdrive/can/parser.cc
@@ -177,6 +177,14 @@ class CANParser {
zmq_connect(subscriber, tcp_addr_char);
+ // drain sendcan to delete any stale messages from previous runs
+ zmq_msg_t msgDrain;
+ zmq_msg_init(&msgDrain);
+ int err = 0;
+ while(err >= 0) {
+ err = zmq_msg_recv(&msgDrain, subscriber, ZMQ_DONTWAIT);
+ }
+
dbc = dbc_lookup(dbc_name);
assert(dbc);
diff --git a/selfdrive/car/__init__.py b/selfdrive/car/__init__.py
index 0473c8874f7cdc..f5c30921a0549b 100644
--- a/selfdrive/car/__init__.py
+++ b/selfdrive/car/__init__.py
@@ -24,3 +24,24 @@ def apply_std_steer_torque_limits(apply_torque, apply_torque_last, driver_torque
min(apply_torque_last + LIMITS.STEER_DELTA_DOWN, LIMITS.STEER_DELTA_UP))
return int(round(apply_torque))
+
+
+def apply_toyota_steer_torque_limits(apply_torque, apply_torque_last, motor_torque, LIMITS):
+
+ # limits due to comparison of commanded torque VS motor reported torque
+ max_lim = min(max(motor_torque + LIMITS.STEER_ERROR_MAX, LIMITS.STEER_ERROR_MAX), LIMITS.STEER_MAX)
+ min_lim = max(min(motor_torque - LIMITS.STEER_ERROR_MAX, -LIMITS.STEER_ERROR_MAX), -LIMITS.STEER_MAX)
+
+ apply_torque = clip(apply_torque, min_lim, max_lim)
+
+ # slow rate if steer torque increases in magnitude
+ if apply_torque_last > 0:
+ apply_torque = clip(apply_torque,
+ max(apply_torque_last - LIMITS.STEER_DELTA_DOWN, -LIMITS.STEER_DELTA_UP),
+ apply_torque_last + LIMITS.STEER_DELTA_UP)
+ else:
+ apply_torque = clip(apply_torque,
+ apply_torque_last - LIMITS.STEER_DELTA_UP,
+ min(apply_torque_last + LIMITS.STEER_DELTA_DOWN, LIMITS.STEER_DELTA_UP))
+
+ return int(round(apply_torque))
diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py
index dbc392cb23e584..58cde11bdf293c 100644
--- a/selfdrive/car/car_helpers.py
+++ b/selfdrive/car/car_helpers.py
@@ -39,6 +39,7 @@ def _get_interface_names():
interfaces = load_interfaces(_get_interface_names())
+# BOUNTY: every added fingerprint in selfdrive/car/*/values.py is a $100 coupon code on shop.comma.ai
# **** for use live only ****
def fingerprint(logcan, timeout):
if os.getenv("SIMULATOR2") is not None:
diff --git a/selfdrive/car/chrysler/__init__.py b/selfdrive/car/chrysler/__init__.py
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/selfdrive/car/chrysler/carcontroller.py b/selfdrive/car/chrysler/carcontroller.py
new file mode 100644
index 00000000000000..d6561768cace2f
--- /dev/null
+++ b/selfdrive/car/chrysler/carcontroller.py
@@ -0,0 +1,92 @@
+from cereal import car
+from selfdrive.boardd.boardd import can_list_to_can_capnp
+from selfdrive.car import apply_toyota_steer_torque_limits
+from selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, \
+ create_wheel_buttons, create_lkas_heartbit, \
+ create_chimes
+from selfdrive.car.chrysler.values import ECU
+from selfdrive.can.packer import CANPacker
+
+AudibleAlert = car.CarControl.HUDControl.AudibleAlert
+LOUD_ALERTS = [AudibleAlert.chimeWarning1, AudibleAlert.chimeWarning2, AudibleAlert.chimeWarningRepeat]
+
+class SteerLimitParams:
+ STEER_MAX = 261 # 262 faults
+ STEER_DELTA_UP = 3 # 3 is stock. 100 is fine. 200 is too much it seems
+ STEER_DELTA_DOWN = 3 # no faults on the way down it seems
+ STEER_ERROR_MAX = 80
+
+
+class CarController(object):
+ def __init__(self, dbc_name, car_fingerprint, enable_camera):
+ self.braking = False
+ # redundant safety check with the board
+ self.controls_allowed = True
+ self.apply_steer_last = 0
+ self.ccframe = 0
+ self.prev_frame = -1
+ self.car_fingerprint = car_fingerprint
+ self.alert_active = False
+ self.send_chime = False
+
+ self.fake_ecus = set()
+ if enable_camera:
+ self.fake_ecus.add(ECU.CAM)
+
+ self.packer = CANPacker(dbc_name)
+
+
+ def update(self, sendcan, enabled, CS, frame, actuators,
+ pcm_cancel_cmd, hud_alert, audible_alert):
+
+ # this seems needed to avoid steerign faults and to force the sync with the EPS counter
+ if self.prev_frame == frame:
+ return
+
+ # *** compute control surfaces ***
+ # steer torque
+ apply_steer = actuators.steer * SteerLimitParams.STEER_MAX
+ apply_steer = apply_toyota_steer_torque_limits(apply_steer, self.apply_steer_last,
+ CS.steer_torque_motor, SteerLimitParams)
+
+ moving_fast = CS.v_ego > CS.CP.minSteerSpeed # for status message
+ lkas_active = moving_fast and enabled
+
+ if not lkas_active:
+ apply_steer = 0
+
+ self.apply_steer_last = apply_steer
+
+ if audible_alert in LOUD_ALERTS:
+ self.send_chime = True
+
+ can_sends = []
+
+ #*** control msgs ***
+
+ if self.send_chime:
+ new_msg = create_chimes(AudibleAlert)
+ can_sends.append(new_msg)
+ if audible_alert not in LOUD_ALERTS:
+ self.send_chime = False
+
+ if pcm_cancel_cmd:
+ # TODO: would be better to start from frame_2b3
+ new_msg = create_wheel_buttons(self.ccframe)
+ can_sends.append(new_msg)
+
+ # frame is 100Hz (0.01s period)
+ if (self.ccframe % 10 == 0): # 0.1s period
+ new_msg = create_lkas_heartbit(self.car_fingerprint)
+ can_sends.append(new_msg)
+
+ if (self.ccframe % 25 == 0): # 0.25s period
+ new_msg = create_lkas_hud(CS.gear_shifter, lkas_active, hud_alert, self.car_fingerprint)
+ can_sends.append(new_msg)
+
+ new_msg = create_lkas_command(self.packer, int(apply_steer), frame)
+ can_sends.append(new_msg)
+
+ self.ccframe += 1
+ self.prev_frame = frame
+ sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan').to_bytes())
diff --git a/selfdrive/car/chrysler/carstate.py b/selfdrive/car/chrysler/carstate.py
new file mode 100644
index 00000000000000..2a0569edad6c9e
--- /dev/null
+++ b/selfdrive/car/chrysler/carstate.py
@@ -0,0 +1,142 @@
+from selfdrive.can.parser import CANParser
+from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD
+from common.kalman.simple_kalman import KF1D
+import numpy as np
+
+
+def parse_gear_shifter(can_gear):
+ if can_gear == 0x1:
+ return "park"
+ elif can_gear == 0x2:
+ return "reverse"
+ elif can_gear == 0x3:
+ return "neutral"
+ elif can_gear == 0x4:
+ return "drive"
+ return "unknown"
+
+
+def get_can_parser(CP):
+
+ signals = [
+ # sig_name, sig_address, default
+ ("PRNDL", "GEAR", 0),
+ ("DOOR_OPEN_FL", "DOORS", 0),
+ ("DOOR_OPEN_FR", "DOORS", 0),
+ ("DOOR_OPEN_RL", "DOORS", 0),
+ ("DOOR_OPEN_RR", "DOORS", 0),
+ ("BRAKE_PRESSED_2", "BRAKE_2", 0),
+ ("ACCEL_PEDAL", "ACCEL_PEDAL_MSG", 0),
+ ("SPEED_LEFT", "SPEED_1", 0),
+ ("SPEED_RIGHT", "SPEED_1", 0),
+ ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0),
+ ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0),
+ ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0),
+ ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0),
+ ("STEER_ANGLE", "STEERING", 0),
+ ("STEERING_RATE", "STEERING", 0),
+ ("TURN_SIGNALS", "STEERING_LEVERS", 0),
+ ("ACC_STATUS_2", "ACC_2", 0),
+ ("HIGH_BEAM_FLASH", "STEERING_LEVERS", 0),
+ ("ACC_SPEED_CONFIG_KPH", "DASHBOARD", 0),
+ ("TORQUE_DRIVER", "EPS_STATUS", 0),
+ ("TORQUE_MOTOR", "EPS_STATUS", 0),
+ ("LKAS_STATE", "EPS_STATUS", 1),
+ ("COUNTER", "EPS_STATUS", -1),
+ ("TRACTION_OFF", "TRACTION_BUTTON", 0),
+ ("SEATBELT_DRIVER_UNLATCHED", "SEATBELT_STATUS", 0),
+ ("COUNTER", "WHEEL_BUTTONS", -1), # incrementing counter for 23b
+ ]
+
+ # It's considered invalid if it is not received for 10x the expected period (1/f).
+ checks = [
+ # sig_address, frequency
+ ("BRAKE_2", 50),
+ ("EPS_STATUS", 100),
+ ("SPEED_1", 100),
+ ("WHEEL_SPEEDS", 50),
+ ("STEERING", 100),
+ ("ACC_2", 50),
+ ]
+
+ return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)
+
+
+class CarState(object):
+ def __init__(self, CP):
+
+ self.CP = CP
+ self.left_blinker_on = 0
+ self.right_blinker_on = 0
+
+ # initialize can parser
+ self.car_fingerprint = CP.carFingerprint
+
+ # vEgo kalman filter
+ dt = 0.01
+ # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]])
+ # R = 1e3
+ self.v_ego_kf = KF1D(x0=np.matrix([[0.0], [0.0]]),
+ A=np.matrix([[1.0, dt], [0.0, 1.0]]),
+ C=np.matrix([1.0, 0.0]),
+ K=np.matrix([[0.12287673], [0.29666309]]))
+ self.v_ego = 0.0
+
+
+ def update(self, cp):
+ # copy can_valid
+ self.can_valid = cp.can_valid
+
+ # update prevs, update must run once per loop
+ self.prev_left_blinker_on = self.left_blinker_on
+ self.prev_right_blinker_on = self.right_blinker_on
+
+ self.frame_23b = int(cp.vl["WHEEL_BUTTONS"]['COUNTER'])
+ self.frame = int(cp.vl["EPS_STATUS"]['COUNTER'])
+
+ self.door_all_closed = not any([cp.vl["DOORS"]['DOOR_OPEN_FL'],
+ cp.vl["DOORS"]['DOOR_OPEN_FR'],
+ cp.vl["DOORS"]['DOOR_OPEN_RL'],
+ cp.vl["DOORS"]['DOOR_OPEN_RR']])
+ self.seatbelt = (cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_UNLATCHED'] == 0)
+
+ self.brake_pressed = cp.vl["BRAKE_2"]['BRAKE_PRESSED_2'] == 5 # human-only
+ self.pedal_gas = cp.vl["ACCEL_PEDAL_MSG"]['ACCEL_PEDAL']
+ self.car_gas = self.pedal_gas
+ self.esp_disabled = (cp.vl["TRACTION_BUTTON"]['TRACTION_OFF'] == 1)
+
+ self.v_wheel_fl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FL']
+ self.v_wheel_rr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RR']
+ self.v_wheel_rl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RL']
+ self.v_wheel_fr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FR']
+ self.v_wheel = (cp.vl['SPEED_1']['SPEED_LEFT'] + cp.vl['SPEED_1']['SPEED_RIGHT']) / 2.
+
+ # Kalman filter
+ if abs(self.v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed
+ self.v_ego_x = np.matrix([[self.v_wheel], [0.0]])
+
+ self.v_ego_raw = self.v_wheel
+ v_ego_x = self.v_ego_kf.update(self.v_wheel)
+ self.v_ego = float(v_ego_x[0])
+ self.a_ego = float(v_ego_x[1])
+ self.standstill = not self.v_wheel > 0.001
+
+ self.angle_steers = cp.vl["STEERING"]['STEER_ANGLE']
+ self.angle_steers_rate = cp.vl["STEERING"]['STEERING_RATE']
+ self.gear_shifter = parse_gear_shifter(cp.vl['GEAR']['PRNDL'])
+ self.main_on = cp.vl["ACC_2"]['ACC_STATUS_2'] == 7 # ACC is green.
+ self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1
+ self.right_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2
+
+ self.steer_torque_driver = cp.vl["EPS_STATUS"]["TORQUE_DRIVER"]
+ self.steer_torque_motor = cp.vl["EPS_STATUS"]["TORQUE_MOTOR"]
+ self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD
+ steer_state = cp.vl["EPS_STATUS"]["LKAS_STATE"]
+ self.steer_error = steer_state == 4 or (steer_state == 0 and self.v_ego > self.CP.minSteerSpeed)
+
+ self.user_brake = 0
+ self.brake_lights = self.brake_pressed
+ self.v_cruise_pcm = cp.vl["DASHBOARD"]['ACC_SPEED_CONFIG_KPH']
+ self.pcm_acc_status = self.main_on
+
+ self.generic_toggle = bool(cp.vl["STEERING_LEVERS"]['HIGH_BEAM_FLASH'])
diff --git a/selfdrive/car/chrysler/chryslercan.py b/selfdrive/car/chrysler/chryslercan.py
new file mode 100644
index 00000000000000..93059001007d00
--- /dev/null
+++ b/selfdrive/car/chrysler/chryslercan.py
@@ -0,0 +1,121 @@
+from cereal import car
+from selfdrive.car.chrysler.values import CAR
+
+
+VisualAlert = car.CarControl.HUDControl.VisualAlert
+AudibleAlert = car.CarControl.HUDControl.AudibleAlert
+
+
+def calc_checksum(data):
+ """This function does not want the checksum byte in the input data.
+
+ jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf
+ """
+ end_index = len(data)
+ index = 0
+ checksum = 0xFF
+ temp_chk = 0;
+ bit_sum = 0;
+ if(end_index <= index):
+ return False
+ for index in range(0, end_index):
+ shift = 0x80
+ curr = data[index]
+ iterate = 8
+ while(iterate > 0):
+ iterate -= 1
+ bit_sum = curr & shift;
+ temp_chk = checksum & 0x80
+ if (bit_sum != 0):
+ bit_sum = 0x1C
+ if (temp_chk != 0):
+ bit_sum = 1
+ checksum = checksum << 1
+ temp_chk = checksum | 1
+ bit_sum ^= temp_chk
+ else:
+ if (temp_chk != 0):
+ bit_sum = 0x1D
+ checksum = checksum << 1
+ bit_sum ^= checksum
+ checksum = bit_sum
+ shift = shift >> 1
+ return ~checksum & 0xFF
+
+
+def make_can_msg(addr, dat):
+ return [addr, 0, dat, 0]
+
+def create_lkas_heartbit(car_fingerprint):
+ # LKAS_HEARTBIT (729) Lane-keeping heartbeat.
+ msg = '0000000820'.decode('hex') # 2017
+ return make_can_msg(0x2d9, msg)
+
+def create_lkas_hud(gear, lkas_active, hud_alert, car_fingerprint):
+ # LKAS_HUD (678) Controls what lane-keeping icon is displayed.
+
+ if hud_alert == VisualAlert.steerRequired:
+ msg = msg = '0000000300000000'.decode('hex')
+ return make_can_msg(0x2a6, msg)
+
+ # TODO: use can packer
+ msg = '0000000000000000'.decode('hex') # park or neutral
+ if car_fingerprint == CAR.PACIFICA_2018:
+ msg = '0064000000000000'.decode('hex') # Have not verified 2018 park with a real car.
+ elif car_fingerprint == CAR.JEEP_CHEROKEE:
+ msg = '00a4000000000000'.decode('hex') # Have not verified 2018 park with a real car.
+ elif car_fingerprint == CAR.PACIFICA_2018_HYBRID:
+ msg = '01a8010000000000'.decode('hex')
+ if (gear == 'drive' or gear == 'reverse'):
+ if lkas_active:
+ msg = '0200060000000000'.decode('hex') # control active, display green.
+ if car_fingerprint == CAR.PACIFICA_2018:
+ msg = '0264060000000000'.decode('hex')
+ elif car_fingerprint == CAR.JEEP_CHEROKEE:
+ msg = '02a4060000000000'.decode('hex')
+ elif car_fingerprint == CAR.PACIFICA_2018_HYBRID:
+ msg = '02a8060000000000'.decode('hex')
+ else:
+ msg = '0100010000000000'.decode('hex') # control off, display white.
+ if car_fingerprint == CAR.PACIFICA_2018:
+ msg = '0164010000000000'.decode('hex')
+ elif car_fingerprint == CAR.JEEP_CHEROKEE:
+ msg = '01a4010000000000'.decode('hex')
+ elif car_fingerprint == CAR.PACIFICA_2018_HYBRID:
+ msg = '01a8010000000000'.decode('hex')
+
+ return make_can_msg(0x2a6, msg)
+
+
+def create_lkas_command(packer, apply_steer, frame):
+ # LKAS_COMMAND (658) Lane-keeping signal to turn the wheel.
+ values = {
+ "LKAS_STEERING_TORQUE": apply_steer,
+ "LKAS_HIGH_TORQUE": 1,
+ "COUNTER": frame % 0x10,
+ }
+
+ dat = packer.make_can_msg("LKAS_COMMAND", 0, values)[2]
+ dat = [ord(i) for i in dat][:-1]
+ checksum = calc_checksum(dat)
+
+ values["CHECKSUM"] = checksum
+ return packer.make_can_msg("LKAS_COMMAND", 0, values)
+
+
+def create_chimes(audible_alert):
+ # '0050' nothing, chime '4f55'
+ if audible_alert == AudibleAlert.none:
+ msg = '0050'.decode('hex')
+ else:
+ msg = '4f55'.decode('hex')
+ return make_can_msg(0x339, msg)
+
+
+def create_wheel_buttons(frame):
+ # WHEEL_BUTTONS (571) Message sent to cancel ACC.
+ start = [0x01] # acc cancel set
+ counter = (frame % 10) << 4
+ dat = start + [counter]
+ dat = dat + [calc_checksum(dat)]
+ return make_can_msg(0x23b, str(bytearray(dat)))
diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py
new file mode 100755
index 00000000000000..f681a45cbf3d54
--- /dev/null
+++ b/selfdrive/car/chrysler/interface.py
@@ -0,0 +1,267 @@
+#!/usr/bin/env python
+from common.realtime import sec_since_boot
+from cereal import car, log
+from selfdrive.config import Conversions as CV
+from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event
+from selfdrive.controls.lib.vehicle_model import VehicleModel
+from selfdrive.car.chrysler.carstate import CarState, get_can_parser
+from selfdrive.car.chrysler.values import ECU, check_ecu_msgs, CAR
+
+try:
+ from selfdrive.car.chrysler.carcontroller import CarController
+except ImportError:
+ CarController = None
+
+
+class CarInterface(object):
+ def __init__(self, CP, sendcan=None):
+ self.CP = CP
+ self.VM = VehicleModel(CP)
+
+ self.frame = 0
+ self.can_invalid_count = 0
+ self.gas_pressed_prev = False
+ self.brake_pressed_prev = False
+ self.cruise_enabled_prev = False
+ self.low_speed_alert = False
+
+ # *** init the major players ***
+ self.CS = CarState(CP)
+
+ self.cp = get_can_parser(CP)
+
+ # sending if read only is False
+ if sendcan is not None:
+ self.sendcan = sendcan
+ self.CC = CarController(self.cp.dbc_name, CP.carFingerprint, CP.enableCamera)
+
+ @staticmethod
+ def compute_gb(accel, speed):
+ return float(accel) / 3.0
+
+ @staticmethod
+ def calc_accel_override(a_ego, a_target, v_ego, v_target):
+ return 1.0
+
+ @staticmethod
+ def get_params(candidate, fingerprint):
+
+ # kg of standard extra cargo to count for drive, gas, etc...
+ std_cargo = 136
+
+ ret = car.CarParams.new_message()
+
+ ret.carName = "chrysler"
+ ret.carFingerprint = candidate
+
+ ret.safetyModel = car.CarParams.SafetyModels.chrysler
+
+ # pedal
+ ret.enableCruise = True
+
+ # FIXME: hardcoding honda civic 2016 touring params so they can be used to
+ # scale unknown params for other cars
+ mass_civic = 2923./2.205 + std_cargo
+ wheelbase_civic = 2.70
+ centerToFront_civic = wheelbase_civic * 0.4
+ centerToRear_civic = wheelbase_civic - centerToFront_civic
+ rotationalInertia_civic = 2500
+ tireStiffnessFront_civic = 85400 * 2.0
+ tireStiffnessRear_civic = 90000 * 2.0
+
+ # Speed conversion: 20, 45 mph
+ ret.steerKpBP, ret.steerKiBP = [[9., 20.], [9., 20.]]
+ ret.wheelbase = 3.089 # in meters for Pacifica Hybrid 2017
+ ret.steerRatio = 16.2 # Pacifica Hybrid 2017
+ ret.mass = 2858 + std_cargo # kg curb weight Pacifica Hybrid 2017
+ ret.steerKpV, ret.steerKiV = [[0.15,0.30], [0.03,0.05]]
+ ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
+ ret.steerActuatorDelay = 0.1
+ ret.steerRateCost = 0.7
+
+ if candidate == CAR.JEEP_CHEROKEE:
+ ret.wheelbase = 2.91 # in meters
+
+ ret.centerToFront = ret.wheelbase * 0.44
+
+ ret.longPidDeadzoneBP = [0., 9.]
+ ret.longPidDeadzoneV = [0., .15]
+
+ ret.minSteerSpeed = 3.8 # m/s
+ ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this
+
+ centerToRear = ret.wheelbase - ret.centerToFront
+ # TODO: get actual value, for now starting with reasonable value for
+ # civic and scaling by mass and wheelbase
+ ret.rotationalInertia = rotationalInertia_civic * \
+ ret.mass * ret.wheelbase**2 / (mass_civic * wheelbase_civic**2)
+
+ # TODO: start from empirically derived lateral slip stiffness for the civic and scale by
+ # mass and CG position, so all cars will have approximately similar dyn behaviors
+ ret.tireStiffnessFront = tireStiffnessFront_civic * \
+ ret.mass / mass_civic * \
+ (centerToRear / ret.wheelbase) / (centerToRear_civic / wheelbase_civic)
+ ret.tireStiffnessRear = tireStiffnessRear_civic * \
+ ret.mass / mass_civic * \
+ (ret.centerToFront / ret.wheelbase) / (centerToFront_civic / wheelbase_civic)
+
+ # no rear steering, at least on the listed cars above
+ ret.steerRatioRear = 0.
+
+ # steer, gas, brake limitations VS speed
+ ret.steerMaxBP = [16. * CV.KPH_TO_MS, 45. * CV.KPH_TO_MS] # breakpoints at 1 and 40 kph
+ ret.steerMaxV = [1., 1.] # 2/3rd torque allowed above 45 kph
+ ret.gasMaxBP = [0.]
+ ret.gasMaxV = [0.5]
+ ret.brakeMaxBP = [5., 20.]
+ ret.brakeMaxV = [1., 0.8]
+
+ ret.enableCamera = not check_ecu_msgs(fingerprint, ECU.CAM)
+ print "ECU Camera Simulated: ", ret.enableCamera
+ ret.openpilotLongitudinalControl = False
+
+ ret.steerLimitAlert = True
+ ret.stoppingControl = False
+ ret.startAccel = 0.0
+
+ ret.longitudinalKpBP = [0., 5., 35.]
+ ret.longitudinalKpV = [3.6, 2.4, 1.5]
+ ret.longitudinalKiBP = [0., 35.]
+ ret.longitudinalKiV = [0.54, 0.36]
+
+ return ret
+
+ # returns a car.CarState
+ def update(self, c):
+ # ******************* do can recv *******************
+ canMonoTimes = []
+
+ self.cp.update(int(sec_since_boot() * 1e9), False)
+
+ self.CS.update(self.cp)
+
+ # create message
+ ret = car.CarState.new_message()
+
+ # speeds
+ ret.vEgo = self.CS.v_ego
+ ret.vEgoRaw = self.CS.v_ego_raw
+ ret.aEgo = self.CS.a_ego
+ ret.yawRate = self.VM.yaw_rate(self.CS.angle_steers * CV.DEG_TO_RAD, self.CS.v_ego)
+ ret.standstill = self.CS.standstill
+ ret.wheelSpeeds.fl = self.CS.v_wheel_fl
+ ret.wheelSpeeds.fr = self.CS.v_wheel_fr
+ ret.wheelSpeeds.rl = self.CS.v_wheel_rl
+ ret.wheelSpeeds.rr = self.CS.v_wheel_rr
+
+ # gear shifter
+ ret.gearShifter = self.CS.gear_shifter
+
+ # gas pedal
+ ret.gas = self.CS.car_gas
+ ret.gasPressed = self.CS.pedal_gas > 0
+
+ # brake pedal
+ ret.brake = self.CS.user_brake
+ ret.brakePressed = self.CS.brake_pressed
+ ret.brakeLights = self.CS.brake_lights
+
+ # steering wheel
+ ret.steeringAngle = self.CS.angle_steers
+ ret.steeringRate = self.CS.angle_steers_rate
+
+ ret.steeringTorque = self.CS.steer_torque_driver
+ ret.steeringPressed = self.CS.steer_override
+
+ # cruise state
+ ret.cruiseState.enabled = self.CS.pcm_acc_status # same as main_on
+ ret.cruiseState.speed = self.CS.v_cruise_pcm * CV.KPH_TO_MS
+ ret.cruiseState.available = self.CS.main_on
+ ret.cruiseState.speedOffset = 0.
+ # ignore standstill in hybrid rav4, since pcm allows to restart without
+ # receiving any special command
+ ret.cruiseState.standstill = False
+
+ # TODO: button presses
+ buttonEvents = []
+
+ if self.CS.left_blinker_on != self.CS.prev_left_blinker_on:
+ be = car.CarState.ButtonEvent.new_message()
+ be.type = 'leftBlinker'
+ be.pressed = self.CS.left_blinker_on != 0
+ buttonEvents.append(be)
+
+ if self.CS.right_blinker_on != self.CS.prev_right_blinker_on:
+ be = car.CarState.ButtonEvent.new_message()
+ be.type = 'rightBlinker'
+ be.pressed = self.CS.right_blinker_on != 0
+ buttonEvents.append(be)
+
+ ret.buttonEvents = buttonEvents
+ ret.leftBlinker = bool(self.CS.left_blinker_on)
+ ret.rightBlinker = bool(self.CS.right_blinker_on)
+
+ ret.doorOpen = not self.CS.door_all_closed
+ ret.seatbeltUnlatched = not self.CS.seatbelt
+ self.low_speed_alert = (ret.vEgo < self.CP.minSteerSpeed)
+
+ ret.genericToggle = self.CS.generic_toggle
+
+ # events
+ events = []
+ if not self.CS.can_valid:
+ self.can_invalid_count += 1
+ if self.can_invalid_count >= 5:
+ events.append(create_event('commIssue', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
+ else:
+ self.can_invalid_count = 0
+ if not ret.gearShifter == 'drive':
+ events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
+ if ret.doorOpen:
+ events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
+ if ret.seatbeltUnlatched:
+ events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
+ if self.CS.esp_disabled:
+ events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
+ if not self.CS.main_on:
+ events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
+ if ret.gearShifter == 'reverse':
+ events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
+ if self.CS.steer_error:
+ events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
+
+ if ret.cruiseState.enabled and not self.cruise_enabled_prev:
+ events.append(create_event('pcmEnable', [ET.ENABLE]))
+ elif not ret.cruiseState.enabled:
+ events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
+
+ # disable on gas pedal and speed isn't zero. Gas pedal is used to resume ACC
+ # from a 3+ second stop.
+ if (ret.gasPressed and (not self.gas_pressed_prev) and ret.vEgo > 2.0):
+ events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
+
+ if self.low_speed_alert:
+ events.append(create_event('belowSteerSpeed', [ET.WARNING]))
+
+ ret.events = events
+ ret.canMonoTimes = canMonoTimes
+
+ self.gas_pressed_prev = ret.gasPressed
+ self.brake_pressed_prev = ret.brakePressed
+ self.cruise_enabled_prev = ret.cruiseState.enabled
+
+ return ret.as_reader()
+
+ # pass in a car.CarControl
+ # to be called @ 100hz
+ def apply(self, c, perception_state=log.Live20Data.new_message()):
+
+ if (self.CS.frame == -1):
+ return False # if we haven't seen a frame 220, then do not update.
+
+ self.frame = self.CS.frame
+ self.CC.update(self.sendcan, c.enabled, self.CS, self.frame,
+ c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert,
+ c.hudControl.audibleAlert)
+
+ return False
diff --git a/selfdrive/car/chrysler/radar_interface.py b/selfdrive/car/chrysler/radar_interface.py
new file mode 100755
index 00000000000000..60eaa4566a8819
--- /dev/null
+++ b/selfdrive/car/chrysler/radar_interface.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+import os
+from selfdrive.can.parser import CANParser
+from cereal import car
+from common.realtime import sec_since_boot
+import zmq
+from selfdrive.services import service_list
+import selfdrive.messaging as messaging
+
+
+RADAR_MSGS_C = range(0x2c2, 0x2d4+2, 2) # c_ messages 706,...,724
+RADAR_MSGS_D = range(0x2a2, 0x2b4+2, 2) # d_ messages
+LAST_MSG = max(RADAR_MSGS_C + RADAR_MSGS_D)
+NUMBER_MSGS = len(RADAR_MSGS_C) + len(RADAR_MSGS_D)
+
+def _create_radard_can_parser():
+ dbc_f = 'chrysler_pacifica_2017_hybrid_private_fusion.dbc'
+ msg_n = len(RADAR_MSGS_C)
+ # list of [(signal name, message name or number, initial values), (...)]
+ # [('RADAR_STATE', 1024, 0),
+ # ('LONG_DIST', 1072, 255),
+ # ('LONG_DIST', 1073, 255),
+ # ('LONG_DIST', 1074, 255),
+ # ('LONG_DIST', 1075, 255),
+
+ # The factor and offset are applied by the dbc parsing library, so the
+ # default values should be after the factor/offset are applied.
+ signals = zip(['LONG_DIST'] * msg_n +
+ ['LAT_DIST'] * msg_n +
+ ['REL_SPEED'] * msg_n,
+ RADAR_MSGS_C * 2 + # LONG_DIST, LAT_DIST
+ RADAR_MSGS_D, # REL_SPEED
+ [0] * msg_n + # LONG_DIST
+ [-1000] * msg_n + # LAT_DIST
+ [-146.278] * msg_n) # REL_SPEED set to 0, factor/offset to this
+ # TODO what are the checks actually used for?
+ # honda only checks the last message,
+ # toyota checks all the messages. Which do we want?
+ checks = zip(RADAR_MSGS_C +
+ RADAR_MSGS_D,
+ [20]*msg_n + # 20Hz (0.05s)
+ [20]*msg_n) # 20Hz (0.05s)
+
+ return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1)
+
+def _address_to_track(address):
+ if address in RADAR_MSGS_C:
+ return (address - RADAR_MSGS_C[0]) / 2
+ if address in RADAR_MSGS_D:
+ return (address - RADAR_MSGS_D[0]) / 2
+ raise ValueError("radar received unexpected address %d" % address)
+
+class RadarInterface(object):
+ def __init__(self, CP):
+ self.pts = {}
+ self.delay = 0.0 # Delay of radar #TUNE
+ self.rcp = _create_radard_can_parser()
+ context = zmq.Context()
+ self.logcan = messaging.sub_sock(context, service_list['can'].port)
+
+ def update(self):
+ canMonoTimes = []
+
+ updated_messages = set() # set of message IDs (sig_addresses) we've seen
+
+ while 1:
+ tm = int(sec_since_boot() * 1e9)
+ updated_messages.update(self.rcp.update(tm, True))
+ if LAST_MSG in updated_messages:
+ break
+
+ ret = car.RadarState.new_message()
+ errors = []
+ if not self.rcp.can_valid:
+ errors.append("commIssue")
+ ret.errors = errors
+ ret.canMonoTimes = canMonoTimes
+
+ for ii in updated_messages: # ii should be the message ID as a number
+ cpt = self.rcp.vl[ii]
+ trackId = _address_to_track(ii)
+
+ if trackId not in self.pts:
+ self.pts[trackId] = car.RadarState.RadarPoint.new_message()
+ self.pts[trackId].trackId = trackId
+ self.pts[trackId].aRel = float('nan')
+ self.pts[trackId].yvRel = float('nan')
+ self.pts[trackId].measured = True
+
+ if 'LONG_DIST' in cpt: # c_* message
+ self.pts[trackId].dRel = cpt['LONG_DIST'] # from front of car
+ # our lat_dist is positive to the right in car's frame.
+ # TODO what does yRel want?
+ self.pts[trackId].yRel = cpt['LAT_DIST'] # in car frame's y axis, left is positive
+ else: # d_* message
+ self.pts[trackId].vRel = cpt['REL_SPEED']
+
+ # We want a list, not a dictionary. Filter out LONG_DIST==0 because that means it's not valid.
+ ret.points = [x for x in self.pts.values() if x.dRel != 0]
+ return ret
+
+if __name__ == "__main__":
+ RI = RadarInterface(None)
+ while 1:
+ ret = RI.update()
+ print(chr(27) + "[2J") # clear screen
+ print ret
diff --git a/selfdrive/car/chrysler/values.py b/selfdrive/car/chrysler/values.py
new file mode 100644
index 00000000000000..8f89924dfc6211
--- /dev/null
+++ b/selfdrive/car/chrysler/values.py
@@ -0,0 +1,77 @@
+from selfdrive.car import dbc_dict
+
+class CAR:
+ PACIFICA_2017_HYBRID = "CHRYSLER PACIFICA HYBRID 2017"
+ PACIFICA_2018_HYBRID = "CHRYSLER PACIFICA HYBRID 2018" # Also covers Pacifica 2019 Hybrid.
+ PACIFICA_2018 = "CHRYSLER PACIFICA 2018"
+ JEEP_CHEROKEE = "JEEP GRAND CHEROKEE V6 2018" # Also covers Tailhawk 2017.
+
+# Unique can messages:
+# Only the hybrids have 270: 8
+# Only the gas have 55: 8, 416: 7
+# For 564, Pacifica 2017 has length 4, whereas Pacifica 2018-19 have length 8.
+# For 924, Pacifica 2017 has length 3, whereas all 2018-19 have length 8.
+# For 560, Pacifica 2019 Hybrid has length 8, whereas all 2017-18 have length 4.
+
+# Jeep Grand Cherokee unique messages:
+# 2017 Trailhawk: 618: 8
+# For 924, Trailhawk 2017 has length 3, whereas 2018 V6 has length 8.
+
+# TODO: verify everything is ok for cars that have commented fingerprint, then upstream them
+
+FINGERPRINTS = {
+ CAR.PACIFICA_2017_HYBRID: [
+ {168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 3, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 956: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1284: 8, 1537: 8, 1538: 8, 1562: 8, 1568: 8, 1856: 8, 1858: 8, 1860: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1892: 8, 2016: 8, 2024: 8},
+ ],
+ CAR.PACIFICA_2018: [{}],
+ #CAR.PACIFICA_2018: [
+ # {170: 8, 171: 8, 189: 7, 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 389: 2, 390: 7, 417: 7, 419: 1, 426: 7, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 4, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 5, 567: 3, 568: 1, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 715: 8, 717: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 967: 4, 969: 8, 977: 8, 979: 7, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1273: 3, 1275: 3, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1922: 7, 1927: 7, 1930: 7, 2016: 8, 2020: 8, 2024: 8, 2028: 8},
+ # {55: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 746: 5, 752: 2, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 8, 926: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8}
+ #],
+ CAR.PACIFICA_2018_HYBRID: [{}],
+ #CAR.PACIFICA_2018_HYBRID: [
+ # {68: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8},
+ # {168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8},
+ # # Pacifica 2019 Hybrid
+ # { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770:8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1538: 8}
+ #],
+ CAR.JEEP_CHEROKEE: [{}],
+ #CAR.JEEP_CHEROKEE: [
+ # # JEEP GRAND CHEROKEE V6 2018
+ # {55: 8, 168: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 785: 8, 788: 3, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 976: 8, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8},
+ # # Jeep Grand Cherokee 2017 Trailhawk
+ # {257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 660: 8, 671: 8, 672: 8, 680: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 783: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8}
+ #],
+}
+
+
+DBC = {
+ CAR.PACIFICA_2017_HYBRID: dbc_dict(
+ 'chrysler_pacifica_2017_hybrid', # 'pt'
+ 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar'
+ CAR.PACIFICA_2018: dbc_dict( # Same DBC file works.
+ 'chrysler_pacifica_2017_hybrid', # 'pt'
+ 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar'
+ CAR.PACIFICA_2018_HYBRID: dbc_dict( # Same DBC file works.
+ 'chrysler_pacifica_2017_hybrid', # 'pt'
+ 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar'
+ CAR.JEEP_CHEROKEE: dbc_dict( # Same DBC file works.
+ 'chrysler_pacifica_2017_hybrid', # 'pt'
+ 'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar'
+}
+
+STEER_THRESHOLD = 120
+
+
+class ECU:
+ CAM = 0 # LKAS camera
+
+
+ECU_FINGERPRINT = {
+ ECU.CAM: 0x2d9, # steer torque cmd
+}
+
+
+def check_ecu_msgs(fingerprint, ecu):
+ # return True if fingerprint contains messages normally sent by a given ecu
+ return ECU_FINGERPRINT[ecu] in fingerprint
diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py
index 5801b365989e88..24c73a3079b23a 100644
--- a/selfdrive/car/gm/carstate.py
+++ b/selfdrive/car/gm/carstate.py
@@ -22,7 +22,6 @@ def get_powertrain_can_parser(CP, canbus):
("AcceleratorPedal", "AcceleratorPedal", 0),
("ACCButtons", "ASCMSteeringButton", CruiseButtons.UNPRESS),
("SteeringWheelAngle", "PSCMSteeringAngle", 0),
- ("SteeringWheelRate", "PSCMSteeringAngle", 0),
("FLWheelSpd", "EBCMWheelSpdFront", 0),
("FRWheelSpd", "EBCMWheelSpdFront", 0),
("RLWheelSpd", "EBCMWheelSpdRear", 0),
@@ -90,7 +89,6 @@ def update(self, pt_cp):
self.standstill = self.v_ego_raw < 0.01
self.angle_steers = pt_cp.vl["PSCMSteeringAngle"]['SteeringWheelAngle']
- self.angle_steers_rate = pt_cp.vl["PSCMSteeringAngle"]['SteeringWheelRate']
self.gear_shifter = parse_gear_shifter(pt_cp.vl["ECMPRDNL"]['PRNDL'])
self.user_brake = pt_cp.vl["EBCMBrakePedalPosition"]['BrakePedalPosition']
diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py
index 854d95ebf3e169..9ec1b9e5d0e12c 100755
--- a/selfdrive/car/gm/interface.py
+++ b/selfdrive/car/gm/interface.py
@@ -214,7 +214,6 @@ def update(self, c):
# steering wheel
ret.steeringAngle = self.CS.angle_steers
- ret.steeringRate = self.CS.angle_steers_rate
# torque and user override. Driver awareness
# timer resets when the user uses the steering wheel.
diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py
index ca69571abb2966..19b0cd9eba82eb 100755
--- a/selfdrive/car/honda/interface.py
+++ b/selfdrive/car/honda/interface.py
@@ -187,7 +187,7 @@ def get_params(candidate, fingerprint):
ret.steerKf = 0.00006 # conservative feed-forward
- if candidate == CAR.CIVIC:
+ if candidate in [CAR.CIVIC, CAR.CIVIC_BOSCH]:
stop_and_go = True
ret.mass = mass_civic
ret.wheelbase = wheelbase_civic
@@ -196,27 +196,15 @@ def get_params(candidate, fingerprint):
tire_stiffness_factor = 1.
# Civic at comma has modified steering FW, so different tuning for the Neo in that car
is_fw_modified = os.getenv("DONGLE_ID") in ['99c94dc769b5d96e']
- ret.steerKpV, ret.steerKiV = [[0.33], [0.10]] if is_fw_modified else [[0.8], [0.24]]
+ ret.steerKpV, ret.steerKiV = [[0.4], [0.12]] if is_fw_modified else [[0.8], [0.24]]
if is_fw_modified:
- ret.steerKf = 0.00003
+ tire_stiffness_factor = 0.9
+ ret.steerKf = 0.00004
ret.longitudinalKpBP = [0., 5., 35.]
ret.longitudinalKpV = [3.6, 2.4, 1.5]
ret.longitudinalKiBP = [0., 35.]
ret.longitudinalKiV = [0.54, 0.36]
- elif candidate == CAR.CIVIC_BOSCH:
- stop_and_go = True
- ret.mass = mass_civic
- ret.wheelbase = wheelbase_civic
- ret.centerToFront = centerToFront_civic
- ret.steerRatio = 14.63 # 10.93 is spec end-to-end
- tire_stiffness_factor = 1.
- ret.steerKpV, ret.steerKiV = [[0.8], [0.24]]
- ret.longitudinalKpBP = [0., 5., 35.]
- ret.longitudinalKpV = [1.2, 0.8, 0.5]
- ret.longitudinalKiBP = [0., 35.]
- ret.longitudinalKiV = [0.18, 0.12]
-
elif candidate in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH):
stop_and_go = True
if not candidate == CAR.ACCORDH: # Hybrid uses same brake msg as hatch
@@ -239,11 +227,7 @@ def get_params(candidate, fingerprint):
ret.centerToFront = ret.wheelbase * 0.37
ret.steerRatio = 18.61 # 15.3 is spec end-to-end
tire_stiffness_factor = 0.72
- # Acura at comma has modified steering FW, so different tuning for the Neo in that car
- is_fw_modified = os.getenv("DONGLE_ID") in ['ff83f397542ab647']
- ret.steerKpV, ret.steerKiV = [[0.45], [0.00]] if is_fw_modified else [[0.8], [0.24]]
- if is_fw_modified:
- ret.steerKf = 0.00003
+ ret.steerKpV, ret.steerKiV = [[0.8], [0.24]]
ret.longitudinalKpBP = [0., 5., 35.]
ret.longitudinalKpV = [1.2, 0.8, 0.5]
ret.longitudinalKiBP = [0., 35.]
diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py
index 451183802085e0..01fd28a5876d79 100644
--- a/selfdrive/car/hyundai/carstate.py
+++ b/selfdrive/car/hyundai/carstate.py
@@ -1,4 +1,4 @@
-from selfdrive.car.hyundai.values import DBC
+from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD
from selfdrive.can.parser import CANParser
from selfdrive.config import Conversions as CV
from common.kalman.simple_kalman import KF1D
@@ -191,7 +191,7 @@ def update(self, cp, cp_cam):
self.left_blinker_flash = cp.vl["CGW1"]['CF_Gway_TurnSigLh']
self.right_blinker_on = cp.vl["CGW1"]['CF_Gway_TSigRHSw']
self.right_blinker_flash = cp.vl["CGW1"]['CF_Gway_TurnSigRh']
- self.steer_override = abs(cp.vl["MDPS11"]['CR_Mdps_DrvTq']) > 100.
+ self.steer_override = abs(cp.vl["MDPS11"]['CR_Mdps_DrvTq']) > STEER_THRESHOLD
self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE
self.steer_error = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail']
self.brake_error = 0
diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py
index c525c0185e939b..5399d827610896 100644
--- a/selfdrive/car/hyundai/interface.py
+++ b/selfdrive/car/hyundai/interface.py
@@ -82,8 +82,8 @@ def get_params(candidate, fingerprint):
ret.steerRatio = 16.55 # 13.8 is spec end-to-end
tire_stiffness_factor = 0.82
- ret.steerKiBP, ret.steerKpBP = [[0.], [0.]]
- ret.steerKpV, ret.steerKiV = [[0.37], [0.1]]
+ ret.steerKiBP, ret.steerKpBP = [[9., 22.], [9., 22.]]
+ ret.steerKpV, ret.steerKiV = [[0.2, 0.35], [0.05, 0.09]]
ret.minSteerSpeed = 0.
elif candidate == CAR.KIA_SORENTO:
ret.steerKf = 0.00005
diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py
index 8de0252410b16b..56b6e605361b5e 100644
--- a/selfdrive/car/hyundai/values.py
+++ b/selfdrive/car/hyundai/values.py
@@ -29,6 +29,9 @@ class Buttons:
}],
CAR.GENESIS: [{
67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1342: 6, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4
+ },
+ {
+ 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1378: 4, 1379: 8, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4
}],
CAR.KIA_SORENTO: [{
67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1384: 8, 1407: 8, 1411: 8, 1419: 8, 1425: 2, 1427: 6, 1444: 8, 1456: 4, 1470: 8, 1489: 1
@@ -38,7 +41,11 @@ class Buttons:
}],
CAR.SANTA_FE: [{
67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1379: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8
- }],
+ },
+ {
+ 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 764: 8, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1186: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8
+ }
+ ],
}
CAMERA_MSGS = [832, 1156, 1191, 1342]
@@ -56,3 +63,5 @@ class Buttons:
CAR.KIA_STINGER: dbc_dict('hyundai_kia_generic', None),
CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None),
}
+
+STEER_THRESHOLD = 100
diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py
index b0c6bf5209f63b..620c9a2ddf81c7 100644
--- a/selfdrive/car/toyota/carcontroller.py
+++ b/selfdrive/car/toyota/carcontroller.py
@@ -1,6 +1,7 @@
from cereal import car
from common.numpy_fast import clip, interp
from selfdrive.boardd.boardd import can_list_to_can_capnp
+from selfdrive.car import apply_toyota_steer_torque_limits
from selfdrive.car.toyota.toyotacan import make_can_msg, create_video_target,\
create_steer_command, create_ui_command, \
create_ipas_steer_command, create_accel_command, \
@@ -18,10 +19,11 @@
ACCEL_SCALE = max(ACCEL_MAX, -ACCEL_MIN)
# Steer torque limits
-STEER_MAX = 1500
-STEER_DELTA_UP = 10 # 1.5s time to peak torque
-STEER_DELTA_DOWN = 25 # always lower than 45 otherwise the Rav4 faults (Prius seems ok with 50)
-STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor
+class SteerLimitParams:
+ STEER_MAX = 1500
+ STEER_DELTA_UP = 10 # 1.5s time to peak torque
+ STEER_DELTA_DOWN = 25 # always lower than 45 otherwise the Rav4 faults (Prius seems ok with 50)
+ STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor
# Steer angle limits (tested at the Crows Landing track and considered ok)
ANGLE_MAX_BP = [0., 5.]
@@ -122,7 +124,7 @@ def __init__(self, dbc_name, car_fingerprint, enable_camera, enable_dsu, enable_
self.packer = CANPacker(dbc_name)
def update(self, sendcan, enabled, CS, frame, actuators,
- pcm_cancel_cmd, hud_alert, audible_alert, forwarding_camera):
+ pcm_cancel_cmd, hud_alert, audible_alert, forwarding_camera, left_line, right_line, lead):
# *** compute control surfaces ***
@@ -132,21 +134,10 @@ def update(self, sendcan, enabled, CS, frame, actuators,
apply_accel = clip(apply_accel * ACCEL_SCALE, ACCEL_MIN, ACCEL_MAX)
# steer torque
- apply_steer = int(round(actuators.steer * STEER_MAX))
+ apply_steer = int(round(actuators.steer * SteerLimitParams.STEER_MAX))
- max_lim = min(max(CS.steer_torque_motor + STEER_ERROR_MAX, STEER_ERROR_MAX), STEER_MAX)
- min_lim = max(min(CS.steer_torque_motor - STEER_ERROR_MAX, -STEER_ERROR_MAX), -STEER_MAX)
+ apply_steer = apply_toyota_steer_torque_limits(apply_steer, self.last_steer, CS.steer_torque_motor, SteerLimitParams)
- apply_steer = clip(apply_steer, min_lim, max_lim)
-
- # slow rate if steer torque increases in magnitude
- if self.last_steer > 0:
- apply_steer = clip(apply_steer, max(self.last_steer - STEER_DELTA_DOWN, - STEER_DELTA_UP), self.last_steer + STEER_DELTA_UP)
- else:
- apply_steer = clip(apply_steer, self.last_steer - STEER_DELTA_UP, min(self.last_steer + STEER_DELTA_DOWN, STEER_DELTA_UP))
-
- # dropping torque immediately might cause eps to temp fault. On the other hand, safety_toyota
- # cuts steer torque immediately anyway TODO: monitor if this is a real issue
# only cut torque when steer state is a known fault
if CS.steer_state in [9, 25]:
self.last_fault_frame = frame
@@ -216,10 +207,11 @@ def update(self, sendcan, enabled, CS, frame, actuators,
# accel cmd comes from DSU, but we can spam can to cancel the system even if we are using lat only control
if (frame % 3 == 0 and ECU.DSU in self.fake_ecus) or (pcm_cancel_cmd and ECU.CAM in self.fake_ecus):
+ lead = lead or CS.v_ego < 12. # at low speed we always assume the lead is present do ACC can be engaged
if ECU.DSU in self.fake_ecus:
- can_sends.append(create_accel_command(self.packer, apply_accel, pcm_cancel_cmd, self.standstill_req))
+ can_sends.append(create_accel_command(self.packer, apply_accel, pcm_cancel_cmd, self.standstill_req, lead))
else:
- can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False))
+ can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead))
if frame % 10 == 0 and ECU.CAM in self.fake_ecus and not forwarding_camera:
for addr in TARGET_IDS:
@@ -239,7 +231,7 @@ def update(self, sendcan, enabled, CS, frame, actuators,
send_ui = False
if (frame % 100 == 0 or send_ui) and ECU.CAM in self.fake_ecus:
- can_sends.append(create_ui_command(self.packer, steer, sound1, sound2))
+ can_sends.append(create_ui_command(self.packer, steer, sound1, sound2, left_line, right_line))
if frame % 100 == 0 and ECU.DSU in self.fake_ecus:
can_sends.append(create_fcw_command(self.packer, fcw))
diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py
index 4f3b53236acb18..03a19b8a288efa 100755
--- a/selfdrive/car/toyota/interface.py
+++ b/selfdrive/car/toyota/interface.py
@@ -350,7 +350,8 @@ def apply(self, c, perception_state=log.Live20Data.new_message()):
self.CC.update(self.sendcan, c.enabled, self.CS, self.frame,
c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert,
- c.hudControl.audibleAlert, self.forwarding_camera)
+ c.hudControl.audibleAlert, self.forwarding_camera,
+ c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leadVisible)
self.frame += 1
return False
diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py
index 6587f32f66c06a..720c0ef60a8a25 100644
--- a/selfdrive/car/toyota/toyotacan.py
+++ b/selfdrive/car/toyota/toyotacan.py
@@ -64,11 +64,14 @@ def create_steer_command(packer, steer, steer_req, raw_cnt):
return packer.make_can_msg("STEERING_LKA", 0, values)
-def create_accel_command(packer, accel, pcm_cancel, standstill_req):
+def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead):
# TODO: find the exact canceling bit that does not create a chime
values = {
"ACCEL_CMD": accel,
- "SET_ME_X63": 0x63,
+ "SET_ME_X01": 1,
+ "DISTANCE": 0,
+ "MINI_CAR": lead,
+ "SET_ME_X3": 3,
"SET_ME_1": 1,
"RELEASE_STANDSTILL": not standstill_req,
"CANCEL_REQ": pcm_cancel,
@@ -86,10 +89,10 @@ def create_fcw_command(packer, fcw):
return packer.make_can_msg("ACC_HUD", 0, values)
-def create_ui_command(packer, steer, sound1, sound2):
+def create_ui_command(packer, steer, sound1, sound2, left_line, right_line):
values = {
- "RIGHT_LINE": 1,
- "LEFT_LINE": 1,
+ "RIGHT_LINE": 1 if right_line else 2,
+ "LEFT_LINE": 1 if left_line else 2,
"SET_ME_X0C": 0x0c,
"SET_ME_X2C": 0x2c,
"SET_ME_X38": 0x38,
diff --git a/selfdrive/common/buffering.c b/selfdrive/common/buffering.c
new file mode 100644
index 00000000000000..9cbb1b86e0df11
--- /dev/null
+++ b/selfdrive/common/buffering.c
@@ -0,0 +1,438 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "common/efd.h"
+
+#include "buffering.h"
+
+void tbuffer_init(TBuffer *tb, int num_bufs, const char* name) {
+ assert(num_bufs >= 3);
+
+ memset(tb, 0, sizeof(TBuffer));
+ tb->reading = (bool*)calloc(num_bufs, sizeof(bool));
+ assert(tb->reading);
+ tb->pending_idx = -1;
+ tb->num_bufs = num_bufs;
+ tb->name = name;
+
+ pthread_mutex_init(&tb->lock, NULL);
+ pthread_cond_init(&tb->cv, NULL);
+ tb->efd = efd_init();
+ assert(tb->efd >= 0);
+}
+
+void tbuffer_init2(TBuffer *tb, int num_bufs, const char* name,
+ void (*release_cb)(void* c, int idx),
+ void* cb_cookie) {
+
+ tbuffer_init(tb, num_bufs, name);
+
+ tb->release_cb = release_cb;
+ tb->cb_cookie = cb_cookie;
+}
+
+int tbuffer_efd(TBuffer *tb) {
+ return tb->efd;
+}
+
+int tbuffer_select(TBuffer *tb) {
+ pthread_mutex_lock(&tb->lock);
+
+ int i;
+ for (i=0; inum_bufs; i++) {
+ if (!tb->reading[i] && i != tb->pending_idx) {
+ break;
+ }
+ }
+ assert(i < tb->num_bufs);
+
+ pthread_mutex_unlock(&tb->lock);
+ return i;
+}
+
+void tbuffer_dispatch(TBuffer *tb, int idx) {
+ pthread_mutex_lock(&tb->lock);
+
+ if (tb->pending_idx != -1) {
+ //printf("tbuffer (%s) dropped!\n", tb->name ? tb->name : "?");
+ if (tb->release_cb) {
+ tb->release_cb(tb->cb_cookie, tb->pending_idx);
+ }
+ tb->pending_idx = -1;
+ }
+
+ tb->pending_idx = idx;
+
+ efd_write(tb->efd);
+ pthread_cond_signal(&tb->cv);
+
+ pthread_mutex_unlock(&tb->lock);
+}
+
+int tbuffer_acquire(TBuffer *tb) {
+ pthread_mutex_lock(&tb->lock);
+
+ if (tb->stopped) {
+ pthread_mutex_unlock(&tb->lock);
+ return -1;
+ }
+
+ while (tb->pending_idx == -1) {
+ pthread_cond_wait(&tb->cv, &tb->lock);
+
+ if (tb->stopped) {
+ pthread_mutex_unlock(&tb->lock);
+ return -1;
+ }
+ }
+
+ efd_clear(tb->efd);
+
+ int ret = tb->pending_idx;
+ assert(ret < tb->num_bufs);
+
+ tb->reading[ret] = true;
+ tb->pending_idx = -1;
+
+ pthread_mutex_unlock(&tb->lock);
+
+ return ret;
+}
+
+static void tbuffer_release_locked(TBuffer *tb, int idx) {
+ assert(idx < tb->num_bufs);
+ if (!tb->reading[idx]) {
+ printf("!! releasing tbuffer we aren't reading %d\n", idx);
+ }
+
+ if (tb->release_cb) {
+ tb->release_cb(tb->cb_cookie, idx);
+ }
+
+ tb->reading[idx] = false;
+}
+
+void tbuffer_release(TBuffer *tb, int idx) {
+ pthread_mutex_lock(&tb->lock);
+ tbuffer_release_locked(tb, idx);
+ pthread_mutex_unlock(&tb->lock);
+}
+
+void tbuffer_release_all(TBuffer *tb) {
+ pthread_mutex_lock(&tb->lock);
+ for (int i=0; inum_bufs; i++) {
+ if (tb->reading[i]) {
+ tbuffer_release_locked(tb, i);
+ }
+ }
+ pthread_mutex_unlock(&tb->lock);
+}
+
+void tbuffer_stop(TBuffer *tb) {
+ pthread_mutex_lock(&tb->lock);
+ tb->stopped = true;
+ efd_write(tb->efd);
+ pthread_cond_signal(&tb->cv);
+ pthread_mutex_unlock(&tb->lock);
+}
+
+
+
+
+
+
+
+
+
+
+
+void pool_init(Pool *s, int num_bufs) {
+ assert(num_bufs > 3);
+
+ memset(s, 0, sizeof(*s));
+ s->num_bufs = num_bufs;
+
+ s->refcnt = (int*)calloc(num_bufs, sizeof(int));
+ s->ts = (int*)calloc(num_bufs, sizeof(int));
+
+ s->counter = 1;
+
+ pthread_mutex_init(&s->lock, NULL);
+}
+
+void pool_init2(Pool *s, int num_bufs,
+ void (*release_cb)(void* c, int idx), void* cb_cookie) {
+
+ pool_init(s, num_bufs);
+ s->cb_cookie = cb_cookie;
+ s->release_cb = release_cb;
+
+}
+
+
+void pool_acquire(Pool *s, int idx) {
+ pthread_mutex_lock(&s->lock);
+
+ assert(idx >= 0 && idx < s->num_bufs);
+
+ s->refcnt[idx]++;
+
+ pthread_mutex_unlock(&s->lock);
+}
+
+static void pool_release_locked(Pool *s, int idx) {
+ // printf("release %d refcnt %d\n", idx, s->refcnt[idx]);
+
+ assert(idx >= 0 && idx < s->num_bufs);
+
+ assert(s->refcnt[idx] > 0);
+ s->refcnt[idx]--;
+
+ // printf("release %d -> %d, %p\n", idx, s->refcnt[idx], s->release_cb);
+ if (s->refcnt[idx] == 0 && s->release_cb) {
+ // printf("call %p\b", s->release_cb);
+ s->release_cb(s->cb_cookie, idx);
+ }
+}
+
+void pool_release(Pool *s, int idx) {
+ pthread_mutex_lock(&s->lock);
+ pool_release_locked(s, idx);
+ pthread_mutex_unlock(&s->lock);
+}
+
+TBuffer* pool_get_tbuffer(Pool *s) {
+ pthread_mutex_lock(&s->lock);
+
+ assert(s->num_tbufs < POOL_MAX_TBUFS);
+ TBuffer* tbuf = &s->tbufs[s->num_tbufs];
+ s->num_tbufs++;
+ tbuffer_init2(tbuf, s->num_bufs,
+ "pool", (void (*)(void *, int))pool_release, s);
+
+ bool stopped = s->stopped;
+ pthread_mutex_unlock(&s->lock);
+
+ // Stop the tbuffer so we can return a valid object.
+ // We must stop here because the pool_stop may have already been called,
+ // in which case tbuffer_stop may never be called again.
+ if (stopped) {
+ tbuffer_stop(tbuf);
+ }
+ return tbuf;
+}
+
+PoolQueue* pool_get_queue(Pool *s) {
+ pthread_mutex_lock(&s->lock);
+
+ int i;
+ for (i = 0; i < POOL_MAX_QUEUES; i++) {
+ if (!s->queues[i].inited) {
+ break;
+ }
+ }
+ assert(i < POOL_MAX_QUEUES);
+
+ PoolQueue *c = &s->queues[i];
+ memset(c, 0, sizeof(*c));
+
+ c->pool = s;
+ c->inited = true;
+
+ c->efd = efd_init();
+ assert(c->efd >= 0);
+
+ c->num_bufs = s->num_bufs;
+ c->num = c->num_bufs+1;
+ c->idx = (int*)malloc(sizeof(int)*c->num);
+ memset(c->idx, -1, sizeof(int)*c->num);
+
+ pthread_mutex_init(&c->lock, NULL);
+ pthread_cond_init(&c->cv, NULL);
+
+ pthread_mutex_unlock(&s->lock);
+ return c;
+}
+
+void pool_release_queue(PoolQueue *c) {
+ Pool *s = c->pool;
+
+ pthread_mutex_lock(&s->lock);
+ pthread_mutex_lock(&c->lock);
+
+ for (int i=0; inum; i++) {
+ if (c->idx[i] != -1) {
+ pool_release_locked(s, c->idx[i]);
+ }
+ }
+
+ close(c->efd);
+ free(c->idx);
+
+ c->inited = false;
+
+ pthread_mutex_unlock(&c->lock);
+
+ pthread_mutex_destroy(&c->lock);
+ pthread_cond_destroy(&c->cv);
+
+ pthread_mutex_unlock(&s->lock);
+}
+
+int pool_select(Pool *s) {
+ pthread_mutex_lock(&s->lock);
+
+ int i;
+ for (i=0; inum_bufs; i++) {
+ if (s->refcnt[i] == 0) {
+ break;
+ }
+ }
+
+ if (i >= s->num_bufs) {
+ // overwrite the oldest
+ // still being using in a queue or tbuffer :/
+
+ int min_k = 0;
+ int min_ts = s->ts[0];
+ for (int k=1; knum_bufs; k++) {
+ if (s->ts[k] < min_ts) {
+ min_ts = s->ts[k];
+ min_k = k;
+ }
+ }
+ i = min_k;
+ printf("pool is full! evicted %d\n", min_k);
+
+ // might be really bad if the user is doing pointery stuff
+ if (s->release_cb) {
+ s->release_cb(s->cb_cookie, min_k);
+ }
+ }
+
+ s->refcnt[i]++;
+
+ s->ts[i] = s->counter;
+ s->counter++;
+
+ pthread_mutex_unlock(&s->lock);
+
+ return i;
+}
+
+void pool_push(Pool *s, int idx) {
+ pthread_mutex_lock(&s->lock);
+
+ // printf("push %d head %d tail %d\n", idx, s->head, s->tail);
+
+ assert(idx >= 0 && idx < s->num_bufs);
+
+ s->ts[idx] = s->counter;
+ s->counter++;
+
+ assert(s->refcnt[idx] > 0);
+ s->refcnt[idx]--; //push is a implcit release
+
+ int num_tbufs = s->num_tbufs;
+ s->refcnt[idx] += num_tbufs;
+
+ // dispatch pool queues
+ for (int i=0; iqueues[i];
+ if (!c->inited) continue;
+
+ pthread_mutex_lock(&c->lock);
+ if (((c->head+1) % c->num) == c->tail) {
+ // queue is full. skip for now
+ pthread_mutex_unlock(&c->lock);
+ continue;
+ }
+
+ s->refcnt[idx]++;
+
+ c->idx[c->head] = idx;
+ c->head = (c->head+1) % c->num;
+ assert(c->head != c->tail);
+ pthread_mutex_unlock(&c->lock);
+
+ efd_write(c->efd);
+ pthread_cond_signal(&c->cv);
+ }
+
+ pthread_mutex_unlock(&s->lock);
+
+ for (int i=0; itbufs[i], idx);
+ }
+}
+
+int poolq_pop(PoolQueue *c) {
+ pthread_mutex_lock(&c->lock);
+
+ if (c->stopped) {
+ pthread_mutex_unlock(&c->lock);
+ return -1;
+ }
+
+ while (c->head == c->tail) {
+ pthread_cond_wait(&c->cv, &c->lock);
+
+ if (c->stopped) {
+ pthread_mutex_unlock(&c->lock);
+ return -1;
+ }
+ }
+
+ // printf("pop head %d tail %d\n", s->head, s->tail);
+
+ assert(c->head != c->tail);
+
+ int r = c->idx[c->tail];
+ c->idx[c->tail] = -1;
+ c->tail = (c->tail+1) % c->num;
+
+ // queue event is level triggered
+ if (c->head == c->tail) {
+ efd_clear(c->efd);
+ }
+
+ // printf("pop %d head %d tail %d\n", r, s->head, s->tail);
+
+ assert(r >= 0 && r < c->num_bufs);
+
+ pthread_mutex_unlock(&c->lock);
+
+ return r;
+}
+
+int poolq_efd(PoolQueue *c) {
+ return c->efd;
+}
+
+void poolq_release(PoolQueue *c, int idx) {
+ pool_release(c->pool, idx);
+}
+
+void pool_stop(Pool *s) {
+ for (int i=0; inum_tbufs; i++) {
+ tbuffer_stop(&s->tbufs[i]);
+ }
+
+ pthread_mutex_lock(&s->lock);
+ s->stopped = true;
+ for (int i=0; iqueues[i];
+ if (!c->inited) continue;
+
+ pthread_mutex_lock(&c->lock);
+ c->stopped = true;
+ pthread_mutex_unlock(&c->lock);
+ efd_write(c->efd);
+ pthread_cond_signal(&c->cv);
+ }
+ pthread_mutex_unlock(&s->lock);
+}
diff --git a/selfdrive/common/buffering.h b/selfdrive/common/buffering.h
new file mode 100644
index 00000000000000..fda4c644928423
--- /dev/null
+++ b/selfdrive/common/buffering.h
@@ -0,0 +1,123 @@
+#ifndef BUFFERING_H
+#define BUFFERING_H
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Tripple buffering helper
+
+typedef struct TBuffer {
+ pthread_mutex_t lock;
+ pthread_cond_t cv;
+ int efd;
+
+ bool* reading;
+ int pending_idx;
+
+ int num_bufs;
+ const char* name;
+
+ void (*release_cb)(void* c, int idx);
+ void *cb_cookie;
+
+ bool stopped;
+} TBuffer;
+
+// num_bufs must be at least the number of buffers that can be acquired simultaniously plus two
+void tbuffer_init(TBuffer *tb, int num_bufs, const char* name);
+
+void tbuffer_init2(TBuffer *tb, int num_bufs, const char* name,
+ void (*release_cb)(void* c, int idx),
+ void* cb_cookie);
+
+// returns an eventfd that signals if a buffer is ready and tbuffer_acquire shouldn't to block.
+// useful to polling on multiple tbuffers.
+int tbuffer_efd(TBuffer *tb);
+
+// Chooses a buffer that's not reading or pending
+int tbuffer_select(TBuffer *tb);
+
+// Called when the writer is done with their buffer
+// - Wakes up the reader if it's waiting
+// - releases the pending buffer if the reader's too slow
+void tbuffer_dispatch(TBuffer *tb, int idx);
+
+// Called when the reader wants a new buffer, will return -1 when stopped
+int tbuffer_acquire(TBuffer *tb);
+
+// Called when the reader is done with their buffer
+void tbuffer_release(TBuffer *tb, int idx);
+
+void tbuffer_release_all(TBuffer *tb);
+
+void tbuffer_stop(TBuffer *tb);
+
+
+
+
+// pool: buffer pool + queue thing...
+
+#define POOL_MAX_TBUFS 8
+#define POOL_MAX_QUEUES 8
+
+typedef struct Pool Pool;
+
+typedef struct PoolQueue {
+ pthread_mutex_t lock;
+ pthread_cond_t cv;
+ Pool* pool;
+ bool inited;
+ bool stopped;
+ int efd;
+ int num_bufs;
+ int num;
+ int head, tail;
+ int* idx;
+} PoolQueue;
+
+int poolq_pop(PoolQueue *s);
+int poolq_efd(PoolQueue *s);
+void poolq_release(PoolQueue *c, int idx);
+
+typedef struct Pool {
+ pthread_mutex_t lock;
+ bool stopped;
+ int num_bufs;
+ int counter;
+
+ int* ts;
+ int* refcnt;
+
+ void (*release_cb)(void* c, int idx);
+ void *cb_cookie;
+
+ int num_tbufs;
+ TBuffer tbufs[POOL_MAX_TBUFS];
+ PoolQueue queues[POOL_MAX_QUEUES];
+} Pool;
+
+void pool_init(Pool *s, int num_bufs);
+void pool_init2(Pool *s, int num_bufs,
+ void (*release_cb)(void* c, int idx), void* cb_cookie);
+
+TBuffer* pool_get_tbuffer(Pool *s);
+
+PoolQueue* pool_get_queue(Pool *s);
+void pool_release_queue(PoolQueue *q);
+
+int pool_select(Pool *s);
+void pool_push(Pool *s, int idx);
+void pool_acquire(Pool *s, int idx);
+void pool_release(Pool *s, int idx);
+void pool_stop(Pool *s);
+
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
diff --git a/selfdrive/common/version.h b/selfdrive/common/version.h
index 422faa02b65add..43c8a9340990e7 100644
--- a/selfdrive/common/version.h
+++ b/selfdrive/common/version.h
@@ -1 +1 @@
-#define COMMA_VERSION "0.5.7-release"
+#define COMMA_VERSION "0.5.8-release"
diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py
index 0a96c233516499..061b9ff81cdb5e 100755
--- a/selfdrive/controls/controlsd.py
+++ b/selfdrive/controls/controlsd.py
@@ -70,7 +70,7 @@ def data_sample(CI, CC, thermal, calibration, health, driver_monitor, gps_locati
if td is not None:
overtemp = td.thermal.thermalStatus >= ThermalStatus.red
- free_space = td.thermal.freeSpace < 0.15 # under 15% of space free no enable allowed
+ free_space = td.thermal.freeSpace < 0.07 # under 7% of space free no enable allowed
low_battery = td.thermal.batteryPercent < 1 # at zero percent battery, OP should not be allowed
# Create events for battery, temperature and disk space
@@ -299,7 +299,7 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
def data_send(perception_state, plan, plan_ts, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, carstate,
carcontrol, live100, livempc, AM, driver_status,
- LaC, LoC, angle_offset, passive):
+ LaC, LoC, angle_offset, passive, start_time):
"""Send actuators and hud commands to the car, send live100 and MPC logging"""
CC = car.CarControl.new_message()
@@ -320,6 +320,8 @@ def data_send(perception_state, plan, plan_ts, CS, CI, CP, VM, state, events, ac
CC.hudControl.speedVisible = isEnabled(state)
CC.hudControl.lanesVisible = isEnabled(state)
CC.hudControl.leadVisible = plan.hasLead
+ CC.hudControl.rightLaneVisible = plan.hasRightLane
+ CC.hudControl.leftLaneVisible = plan.hasLeftLane
CC.hudControl.visualAlert = AM.visual_alert
CC.hudControl.audibleAlert = AM.audible_alert
@@ -365,7 +367,11 @@ def data_send(perception_state, plan, plan_ts, CS, CI, CP, VM, state, events, ac
"jerkFactor": float(plan.jerkFactor),
"angleOffset": float(angle_offset),
"gpsPlannerActive": plan.gpsPlannerActive,
+ "vCurvature": plan.vCurvature,
+ "decelForTurn": plan.decelForTurn,
"cumLagMs": -rk.remaining * 1000.,
+ "startMonoTime": start_time,
+ "mapValid": plan.mapValid,
}
live100.send(dat.to_bytes())
@@ -487,6 +493,7 @@ def controlsd_thread(gctx=None, rate=100, default_bias=0.):
prof = Profiler(False) # off by default
while True:
+ start_time = int(sec_since_boot() * 1e9)
prof.checkpoint("Ratekeeper", ignore=True)
# Sample data and compute car events
@@ -511,7 +518,7 @@ def controlsd_thread(gctx=None, rate=100, default_bias=0.):
# Publish data
CC = data_send(PL.perception_state, plan, plan_ts, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, carstate, carcontrol,
- live100, livempc, AM, driver_status, LaC, LoC, angle_offset, passive)
+ live100, livempc, AM, driver_status, LaC, LoC, angle_offset, passive, start_time)
prof.checkpoint("Sent")
rk.keep_time() # Run at 100Hz
diff --git a/selfdrive/controls/lib/pathplanner.py b/selfdrive/controls/lib/pathplanner.py
index 178b5e6dbb2de4..450a308ae5c722 100644
--- a/selfdrive/controls/lib/pathplanner.py
+++ b/selfdrive/controls/lib/pathplanner.py
@@ -15,6 +15,8 @@ def __init__(self):
self.lane_width_estimate = 3.7
self.lane_width_certainty = 1.0
self.lane_width = 3.7
+ self.l_prob = 0.
+ self.r_prob = 0.
def update(self, v_ego, md):
if md is not None:
diff --git a/selfdrive/controls/lib/planner.py b/selfdrive/controls/lib/planner.py
index b986740113904d..7cb7b789887c3d 100755
--- a/selfdrive/controls/lib/planner.py
+++ b/selfdrive/controls/lib/planner.py
@@ -21,7 +21,7 @@
from selfdrive.controls.lib.radar_helpers import _LEAD_ACCEL_TAU
# Max lateral acceleration, used to caclulate how much to slow down in turns
-A_Y_MAX = 2.0 # m/s^2
+A_Y_MAX = 1.85 # m/s^2
NO_CURVATURE_SPEED = 200. * CV.MPH_TO_MS
_DT = 0.01 # 100Hz
@@ -304,7 +304,10 @@ def __init__(self, CP, fcw_enabled):
self.perception_state = log.Live20Data.new_message()
self.params = Params()
+ self.v_curvature = NO_CURVATURE_SPEED
self.v_speedlimit = NO_CURVATURE_SPEED
+ self.decel_for_turn = False
+ self.map_valid = False
def choose_solution(self, v_cruise_setpoint, enabled):
if enabled:
@@ -394,9 +397,10 @@ def update(self, CS, CP, VM, LaC, LoC, v_cruise_kph, force_slow_decel):
enabled = (LoC.long_control_state == LongCtrlState.pid) or (LoC.long_control_state == LongCtrlState.stopping)
following = self.lead_1.status and self.lead_1.dRel < 45.0 and self.lead_1.vLeadK > CS.vEgo and self.lead_1.aLeadK > 0.0
-
if self.last_live_map_data:
self.v_speedlimit = NO_CURVATURE_SPEED
+ self.v_curvature = NO_CURVATURE_SPEED
+ self.map_valid = self.last_live_map_data.mapValid
# Speed limit
if self.last_live_map_data.speedLimitValid:
@@ -407,7 +411,15 @@ def update(self, CS, CP, VM, LaC, LoC, v_cruise_kph, force_slow_decel):
offset = float(self.params.get("SpeedLimitOffset"))
self.v_speedlimit = speed_limit + offset
- v_cruise_setpoint = min([v_cruise_setpoint, self.v_speedlimit])
+ # Curvature
+ if self.last_live_map_data.curvatureValid:
+ curvature = abs(self.last_live_map_data.curvature)
+ v_curvature = math.sqrt(A_Y_MAX / max(1e-4, curvature))
+ self.v_curvature = min(NO_CURVATURE_SPEED, v_curvature)
+
+ # leave 1m/s margin on vEgo to asses if turn is limiting our speed.
+ self.decel_for_turn = bool(self.v_curvature < min([v_cruise_setpoint, self.v_speedlimit, CS.vEgo + 1.]))
+ v_cruise_setpoint = min([v_cruise_setpoint, self.v_curvature, self.v_speedlimit])
# Calculate speed for normal cruise control
if enabled:
@@ -421,6 +433,12 @@ def update(self, CS, CP, VM, LaC, LoC, v_cruise_kph, force_slow_decel):
accel_limits[1] = min(accel_limits[1], AWARENESS_DECEL)
accel_limits[0] = min(accel_limits[0], accel_limits[1])
+ # Change accel limits based on time remaining to turn
+ if self.decel_for_turn:
+ time_to_turn = max(1.0, self.last_live_map_data.distToTurn / max(self.v_cruise, 1.))
+ required_decel = min(0, (self.v_curvature - self.v_cruise) / time_to_turn)
+ accel_limits[0] = max(accel_limits[0], required_decel)
+
self.v_cruise, self.a_cruise = speed_smoother(self.v_acc_start, self.a_acc_start,
v_cruise_setpoint,
accel_limits[1], accel_limits[0],
@@ -504,10 +522,16 @@ def update(self, CS, CP, VM, LaC, LoC, v_cruise_kph, force_slow_decel):
plan_send.plan.aTarget = self.a_acc_sol
plan_send.plan.vTargetFuture = self.v_acc_future
plan_send.plan.hasLead = self.mpc1.prev_lead_status
+ plan_send.plan.hasLeftLane = bool(self.PP.l_prob > 0.5)
+ plan_send.plan.hasRightLane = bool(self.PP.r_prob > 0.5)
plan_send.plan.longitudinalPlanSource = self.longitudinalPlanSource
plan_send.plan.gpsPlannerActive = self.gps_planner_active
+ plan_send.plan.vCurvature = self.v_curvature
+ plan_send.plan.decelForTurn = self.decel_for_turn
+ plan_send.plan.mapValid = self.map_valid
+
# Send out fcw
fcw = self.fcw and (self.fcw_enabled or LoC.long_control_state != LongCtrlState.off)
plan_send.plan.fcw = fcw
diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py
index b909b4952af7be..c157ba908402da 100755
--- a/selfdrive/controls/radard.py
+++ b/selfdrive/controls/radard.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-import gc
import zmq
import numpy as np
import numpy.matlib
@@ -44,9 +43,10 @@ def calc_transfer_fun(self, dt):
return tf, tfj
-# fuses camera and radar data for best lead detection
+## fuses camera and radar data for best lead detection
+# FIXME: radard has a memory leak of about 50MB/hr
+# BOUNTY: $100 coupon on shop.comma.ai
def radard_thread(gctx=None):
- gc.disable()
set_realtime_priority(2)
# wait for stats about the car to come in from controls
diff --git a/selfdrive/loggerd/loggerd b/selfdrive/loggerd/loggerd
index af3a9b38499153..383fa14cf1c16a 100755
--- a/selfdrive/loggerd/loggerd
+++ b/selfdrive/loggerd/loggerd
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:3f1454e86627a8cd0a9bb59b24bdfe2f76cf991e875177de41139e6ccd8a3051
+oid sha256:55ed3bafdbe1908778383bb5fd310d5a1279b15a84eb85ae1ee65d1107a0752c
size 1630952
diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py
index 2d793064af83d0..6b35776ce011f0 100644
--- a/selfdrive/loggerd/uploader.py
+++ b/selfdrive/loggerd/uploader.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import os
+import re
import time
import stat
import json
@@ -78,6 +79,16 @@ def is_on_wifi():
return "\x00".join("WIFI") in data
+def is_on_hotspot():
+ try:
+ result = subprocess.check_output(["ifconfig", "wlan0"])
+ result = re.findall(r"inet addr:((\d+\.){3}\d+)", result)[0][0]
+
+ is_android = result.startswith('192.168.43.')
+ is_ios = result.startswith('172.20.10.')
+ return (is_android or is_ios)
+ except:
+ return False
class Uploader(object):
def __init__(self, dongle_id, access_token, root):
@@ -256,8 +267,10 @@ def uploader_fn(exit_event):
backoff = 0.1
while True:
-
- should_upload = (params.get("IsUploadVideoOverCellularEnabled") != "0") or is_on_wifi()
+ allow_cellular = (params.get("IsUploadVideoOverCellularEnabled") != "0")
+ on_hotspot = is_on_hotspot()
+ on_wifi = is_on_wifi()
+ should_upload = allow_cellular or (on_wifi and not on_hotspot)
if exit_event.is_set():
return
@@ -273,6 +286,7 @@ def uploader_fn(exit_event):
key, fn, _ = d
+ cloudlog.event("uploader_netcheck", allow_cellular=allow_cellular, is_on_hotspot=on_hotspot, is_on_wifi=on_wifi)
cloudlog.info("to upload %r", d)
success = uploader.upload(key, fn)
if success:
@@ -288,4 +302,3 @@ def main(gctx=None):
if __name__ == "__main__":
main()
-
diff --git a/selfdrive/mapd/mapd.py b/selfdrive/mapd/mapd.py
index e1a9595e8c0c84..1ae7b6aabc82a4 100755
--- a/selfdrive/mapd/mapd.py
+++ b/selfdrive/mapd/mapd.py
@@ -28,7 +28,7 @@
from common.transformations.coordinates import geodetic2ecef
from selfdrive.services import service_list
import selfdrive.messaging as messaging
-from mapd_helpers import LOOKAHEAD_TIME, MAPS_LOOKAHEAD_DISTANCE, Way, circle_through_points
+from mapd_helpers import MAPS_LOOKAHEAD_DISTANCE, Way, circle_through_points
import selfdrive.crash as crash
from selfdrive.version import version, dirty
@@ -42,6 +42,7 @@
query_lock = threading.Lock()
last_query_result = None
last_query_pos = None
+cache_valid = False
def setup_thread_excepthook():
@@ -81,7 +82,7 @@ def build_way_query(lat, lon, radius=50):
def query_thread():
- global last_query_result, last_query_pos
+ global last_query_result, last_query_pos, cache_valid
api = overpy.Overpass(url=OVERPASS_API_URL, headers=OVERPASS_HEADERS, timeout=10.)
while True:
@@ -98,7 +99,10 @@ def query_thread():
if dist < 1000:
continue
- q = build_way_query(last_gps.latitude, last_gps.longitude, radius=2000)
+ if dist > 3000:
+ cache_valid = False
+
+ q = build_way_query(last_gps.latitude, last_gps.longitude, radius=3000)
try:
new_result = api.query(q)
@@ -122,6 +126,7 @@ def query_thread():
query_lock.acquire()
last_query_result = new_result, tree, real_nodes, node_to_way
last_query_pos = last_gps
+ cache_valid = True
query_lock.release()
except Exception as e:
@@ -146,8 +151,6 @@ def mapsd_thread():
dist_to_turn = 0.
road_points = None
- xx = np.arange(0, MAPS_LOOKAHEAD_DISTANCE, 10)
-
while True:
gps = messaging.recv_one(gps_sock)
gps_ext = messaging.recv_one_or_none(gps_external_sock)
@@ -160,14 +163,16 @@ def mapsd_thread():
last_gps = gps
fix_ok = gps.flags & 1
- if not fix_ok or last_query_result is None:
+ if not fix_ok or last_query_result is None or not cache_valid:
cur_way = None
curvature = None
curvature_valid = False
upcoming_curvature = 0.
dist_to_turn = 0.
road_points = None
+ map_valid = False
else:
+ map_valid = True
lat = gps.latitude
lon = gps.longitude
heading = gps.bearing
@@ -184,9 +189,11 @@ def mapsd_thread():
if speed < 10:
curvature_valid = False
+ if curvature_valid and pnts.shape[0] <= 3:
+ curvature_valid = False
# The curvature is valid when at least MAPS_LOOKAHEAD_DISTANCE of road is found
- if curvature_valid and pnts.shape[0] > 3:
+ if curvature_valid:
# Compute the curvature for each point
with np.errstate(divide='ignore'):
circles = [circle_through_points(*p) for p in zip(pnts, pnts[1:], pnts[2:])]
@@ -206,22 +213,31 @@ def mapsd_thread():
dists.append(dists[-1] + np.linalg.norm(p - p_prev))
dists = np.asarray(dists)
dists = dists - dists[closest] + dist_to_closest
+ dists = dists[1:-1]
+
+ close_idx = np.logical_and(dists > 0, dists < 500)
+ dists = dists[close_idx]
+ curvature = curvature[close_idx]
- # TODO: Determine left or right turn
- curvature = np.nan_to_num(curvature)
- curvature_interp = np.interp(xx, dists[1:-1], curvature)
- curvature_lookahead = curvature_interp[:int(speed * LOOKAHEAD_TIME / 10)]
+ if len(curvature):
+ # TODO: Determine left or right turn
+ curvature = np.nan_to_num(curvature)
- # Outlier rejection
- new_curvature = np.percentile(curvature_lookahead, 90)
+ # Outlier rejection
+ new_curvature = np.percentile(curvature, 90, interpolation='lower')
- k = 0.9
- upcoming_curvature = k * upcoming_curvature + (1 - k) * new_curvature
- in_turn_indices = curvature_interp > 0.8 * new_curvature
- if np.any(in_turn_indices):
- dist_to_turn = np.min(xx[in_turn_indices])
+ k = 0.6
+ upcoming_curvature = k * upcoming_curvature + (1 - k) * new_curvature
+ in_turn_indices = curvature > 0.8 * new_curvature
+
+ if np.any(in_turn_indices):
+ dist_to_turn = np.min(dists[in_turn_indices])
+ else:
+ dist_to_turn = 999
else:
+ upcoming_curvature = 0.
dist_to_turn = 999
+
query_lock.release()
dat = messaging.new_message()
@@ -246,8 +262,10 @@ def mapsd_thread():
if road_points is not None:
dat.liveMapData.roadX, dat.liveMapData.roadY = road_points
if curvature is not None:
- dat.liveMapData.roadCurvatureX = map(float, xx)
- dat.liveMapData.roadCurvature = map(float, curvature_interp)
+ dat.liveMapData.roadCurvatureX = map(float, dists)
+ dat.liveMapData.roadCurvature = map(float, curvature)
+
+ dat.liveMapData.mapValid = map_valid
map_data_sock.send(dat.to_bytes())
diff --git a/selfdrive/mapd/mapd_helpers.py b/selfdrive/mapd/mapd_helpers.py
index 6d84fbd7d504ca..09239f6a2f3d0b 100644
--- a/selfdrive/mapd/mapd_helpers.py
+++ b/selfdrive/mapd/mapd_helpers.py
@@ -33,7 +33,12 @@ def parse_speed_unit(max_speed):
max_speed = max_speed.replace(' mph', '')
conversion = CV.MPH_TO_MS
- return float(max_speed) * conversion
+ try:
+ max_speed = float(max_speed) * conversion
+ except ValueError:
+ max_speed = None
+
+ return max_speed
class Way:
@@ -131,17 +136,20 @@ def max_speed(self):
if 'maxspeed' in tags:
max_speed = parse_speed_unit(tags['maxspeed'])
- if 'maxspeed:conditional' in tags:
- max_speed_cond, cond = tags['maxspeed:conditional'].split(' @ ')
- cond = cond[1:-1]
-
- start, end = cond.split('-')
- now = datetime.now() # TODO: Get time and timezone from gps fix so this will work correctly on replays
- start = datetime.strptime(start, "%H:%M").replace(year=now.year, month=now.month, day=now.day)
- end = datetime.strptime(end, "%H:%M").replace(year=now.year, month=now.month, day=now.day)
-
- if start <= now <= end:
- max_speed = parse_speed_unit(max_speed_cond)
+ try:
+ if 'maxspeed:conditional' in tags:
+ max_speed_cond, cond = tags['maxspeed:conditional'].split(' @ ')
+ cond = cond[1:-1]
+
+ start, end = cond.split('-')
+ now = datetime.now() # TODO: Get time and timezone from gps fix so this will work correctly on replays
+ start = datetime.strptime(start, "%H:%M").replace(year=now.year, month=now.month, day=now.day)
+ end = datetime.strptime(end, "%H:%M").replace(year=now.year, month=now.month, day=now.day)
+
+ if start <= now <= end:
+ max_speed = parse_speed_unit(max_speed_cond)
+ except ValueError:
+ pass
return max_speed
@@ -191,10 +199,29 @@ def next_way(self, query_results, lat, lon, heading, backwards=False):
way = None
try:
# Simple heuristic to find next way
- ways = [w for w in ways if w.id != self.id and w.tags['highway'] == self.way.tags['highway']]
+ ways = [w for w in ways if w.id != self.id]
+ ways = [w for w in ways if w.nodes[0] == node]
+
+ # Filter on highway tag
+ acceptable_tags = list()
+ cur_tag = self.way.tags['highway']
+ acceptable_tags.append(cur_tag)
+ if cur_tag == 'motorway_link':
+ acceptable_tags.append('motorway')
+ acceptable_tags.append('trunk')
+ acceptable_tags.append('primary')
+ ways = [w for w in ways if w.tags['highway'] in acceptable_tags]
+
+ # Filter on number of lanes
+ cur_num_lanes = int(self.way.tags['lanes'])
+ if len(ways) > 1:
+ ways = [w for w in ways if int(w.tags['lanes']) == cur_num_lanes]
+ if len(ways) > 1:
+ ways = [w for w in ways if int(w.tags['lanes']) > cur_num_lanes]
if len(ways) == 1:
way = Way(ways[0])
- except KeyError:
+
+ except (KeyError, ValueError):
pass
return way
diff --git a/selfdrive/sensord/gpsd b/selfdrive/sensord/gpsd
index c0357f1201e07c..8ca756fb371ee1 100755
--- a/selfdrive/sensord/gpsd
+++ b/selfdrive/sensord/gpsd
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:9c53ec49b9f3c15a9d5475fabde243ae8629a6a0173f37e374183acdfdf9e332
+oid sha256:f21b25b1bede44778eadba4e647eaace2a91617518d80a738947d4301ff54733
size 1171544
diff --git a/selfdrive/sensord/sensord b/selfdrive/sensord/sensord
index caad704ef506ca..1e428fb54f62a4 100755
--- a/selfdrive/sensord/sensord
+++ b/selfdrive/sensord/sensord
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:5030be4f52ea7ee58af280a168197c15fb53666c0f08d5be3382b445270e58b8
+oid sha256:10fb68f4fef47fa7a16bfdeca0c262c4c6aab6bbde3693122baf177e12da4679
size 1159016
diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py
index 78c4aa1490043f..fea5a896846756 100755
--- a/selfdrive/thermald.py
+++ b/selfdrive/thermald.py
@@ -111,10 +111,10 @@ def check_car_battery_voltage(should_start, health, charging_disabled):
# - there are health packets from panda, and;
# - 12V battery voltage is too low, and;
# - onroad isn't started
- if charging_disabled and (health is None or health.health.voltage > 11500):
+ if charging_disabled and (health is None or health.health.voltage > 11800):
charging_disabled = False
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
- elif not charging_disabled and health is not None and health.health.voltage < 11000 and not should_start:
+ elif not charging_disabled and health is not None and health.health.voltage < 11500 and not should_start:
charging_disabled = True
os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled')
diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c
index dddf15f7e7167e..33e35d3810f4f2 100644
--- a/selfdrive/ui/ui.c
+++ b/selfdrive/ui/ui.c
@@ -48,6 +48,7 @@
#define ALERTSIZE_FULL 3
#define UI_BUF_COUNT 4
+//#define DEBUG_TURN
const int vwp_w = 1920;
const int vwp_h = 1080;
@@ -64,6 +65,8 @@ const int header_h = 420;
const int footer_h = 280;
const int footer_y = vwp_h-bdr_s-footer_h;
+const int UI_FREQ = 60; // Hz
+
const uint8_t bg_colors[][4] = {
[STATUS_STOPPED] = {0x07, 0x23, 0x39, 0xff},
[STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xff},
@@ -115,9 +118,12 @@ typedef struct UIScene {
float v_cruise;
uint64_t v_cruise_update_ts;
float v_ego;
+ float v_curvature;
+ bool decel_for_turn;
float speedlimit;
bool speedlimit_valid;
+ bool map_valid;
float curvature;
int engaged;
@@ -168,7 +174,9 @@ typedef struct UIState {
int font_sans_semibold;
int font_sans_bold;
int img_wheel;
+ int img_turn;
int img_face;
+ int img_map;
zsock_t *thermal_sock;
void *thermal_sock_raw;
@@ -228,9 +236,11 @@ typedef struct UIState {
int volume_timeout;
int speed_lim_off_timeout;
int is_metric_timeout;
+ int limit_set_speed_timeout;
int status;
bool is_metric;
+ bool limit_set_speed;
float speed_lim_off;
bool is_ego_over_limit;
bool passive;
@@ -279,7 +289,7 @@ static void set_volume(UIState *s, int volume) {
sprintf(volume_change_cmd, "service call audio 3 i32 3 i32 %d i32 1", volume);
// 5 second timeout at 60fps
- s->volume_timeout = 5 * 60;
+ s->volume_timeout = 5 * UI_FREQ;
int volume_changed = system(volume_change_cmd);
}
@@ -296,7 +306,7 @@ static void read_speed_lim_off(UIState *s) {
s->speed_lim_off = strtod(speed_lim_off, NULL);
free(speed_lim_off);
}
- s->speed_lim_off_timeout = 2 * 60; // 2Hz
+ s->speed_lim_off_timeout = 2 * UI_FREQ; // 0.5Hz
}
static void read_is_metric(UIState *s) {
@@ -306,9 +316,18 @@ static void read_is_metric(UIState *s) {
s->is_metric = is_metric[0] == '1';
free(is_metric);
}
- s->is_metric_timeout = 2 * 60; // 2Hz
+ s->is_metric_timeout = 2 * UI_FREQ; // 0.5Hz
}
+static void read_limit_set_speed(UIState *s) {
+ char *limit_set_speed;
+ const int result = read_db_value(NULL, "LimitSetSpeed", &limit_set_speed, NULL);
+ if (result == 0) {
+ s->limit_set_speed = limit_set_speed[0] == '1';
+ free(limit_set_speed);
+ }
+ s->limit_set_speed_timeout = 2 * UI_FREQ; // 0.2Hz
+}
static const char frame_vertex_shader[] =
"attribute vec4 aPosition;\n"
"attribute vec4 aTexCoord;\n"
@@ -475,9 +494,15 @@ static void ui_init(UIState *s) {
assert(s->img_wheel >= 0);
s->img_wheel = nvgCreateImage(s->vg, "../assets/img_chffr_wheel.png", 1);
+ assert(s->img_turn >= 0);
+ s->img_turn = nvgCreateImage(s->vg, "../assets/img_trafficSign_turn.png", 1);
+
assert(s->img_face >= 0);
s->img_face = nvgCreateImage(s->vg, "../assets/img_driver_face.png", 1);
+ assert(s->img_map >= 0);
+ s->img_map = nvgCreateImage(s->vg, "../assets/img_map.png", 1);
+
// init gl
s->frame_program = load_program(frame_vertex_shader, frame_fragment_shader);
assert(s->frame_program);
@@ -558,7 +583,9 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
read_speed_lim_off(s);
read_is_metric(s);
- s->is_metric_timeout = 60; // offset so values isn't read together with limit offset
+ read_limit_set_speed(s);
+ s->is_metric_timeout = UI_FREQ / 2; // offset so values isn't read together with limit offset
+ s->limit_set_speed_timeout = UI_FREQ; // offset so values isn't read together with limit offset
}
static void ui_draw_transformed_box(UIState *s, uint32_t color) {
@@ -1013,6 +1040,18 @@ static void ui_draw_vision_maxspeed(UIState *s) {
nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 100));
nvgText(s->vg, viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 242, "N/A", NULL);
}
+
+#ifdef DEBUG_TURN
+ if (s->scene.decel_for_turn && s->scene.engaged){
+ int v_curvature = s->scene.v_curvature * 2.2369363 + 0.5;
+ snprintf(maxspeed_str, sizeof(maxspeed_str), "%d", v_curvature);
+ nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255));
+ nvgFontSize(s->vg, 25*2.5);
+ nvgText(s->vg, 200 + viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 148, "TURN", NULL);
+ nvgFontSize(s->vg, 50*2.5);
+ nvgText(s->vg, 200 + viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 242, maxspeed_str, NULL);
+ }
+#endif
}
static void ui_draw_vision_speedlimit(UIState *s) {
@@ -1135,7 +1174,7 @@ static void ui_draw_vision_speed(UIState *s) {
}
}
-static void ui_draw_vision_wheel(UIState *s) {
+static void ui_draw_vision_event(UIState *s) {
const UIScene *scene = &s->scene;
const int ui_viz_rx = scene->ui_viz_rx;
const int ui_viz_rw = scene->ui_viz_rw;
@@ -1143,35 +1182,76 @@ static void ui_draw_vision_wheel(UIState *s) {
const int viz_event_x = ((ui_viz_rx + ui_viz_rw) - (viz_event_w + (bdr_s*2)));
const int viz_event_y = (box_y + (bdr_s*1.5));
const int viz_event_h = (header_h - (bdr_s*1.5));
- // draw steering wheel
- const int bg_wheel_size = 96;
- const int bg_wheel_x = viz_event_x + (viz_event_w-bg_wheel_size);
- const int bg_wheel_y = viz_event_y + (bg_wheel_size/2);
- const int img_wheel_size = bg_wheel_size*1.5;
- const int img_wheel_x = bg_wheel_x-(img_wheel_size/2);
- const int img_wheel_y = bg_wheel_y-25;
- float img_wheel_alpha = 0.1f;
- bool is_engaged = (s->status == STATUS_ENGAGED);
- bool is_warning = (s->status == STATUS_WARNING);
- bool is_engageable = scene->engageable;
- if (is_engaged || is_warning || is_engageable) {
+ if (s->scene.decel_for_turn && s->scene.engaged && s->limit_set_speed) {
+ // draw winding road sign
+ const int img_turn_size = 160*1.5;
+ const int img_turn_x = viz_event_x-(img_turn_size/4);
+ const int img_turn_y = viz_event_y+bdr_s-25;
+ float img_turn_alpha = 1.0f;
nvgBeginPath(s->vg);
- nvgCircle(s->vg, bg_wheel_x, (bg_wheel_y + (bdr_s*1.5)), bg_wheel_size);
- if (is_engaged) {
- nvgFillColor(s->vg, nvgRGBA(23, 134, 68, 255));
- } else if (is_warning) {
- nvgFillColor(s->vg, nvgRGBA(218, 111, 37, 255));
- } else if (is_engageable) {
- nvgFillColor(s->vg, nvgRGBA(23, 51, 73, 255));
+ NVGpaint imgPaint = nvgImagePattern(s->vg, img_turn_x, img_turn_y,
+ img_turn_size, img_turn_size, 0, s->img_turn, img_turn_alpha);
+ nvgRect(s->vg, img_turn_x, img_turn_y, img_turn_size, img_turn_size);
+ nvgFillPaint(s->vg, imgPaint);
+ nvgFill(s->vg);
+ } else {
+ // draw steering wheel
+ const int bg_wheel_size = 96;
+ const int bg_wheel_x = viz_event_x + (viz_event_w-bg_wheel_size);
+ const int bg_wheel_y = viz_event_y + (bg_wheel_size/2);
+ const int img_wheel_size = bg_wheel_size*1.5;
+ const int img_wheel_x = bg_wheel_x-(img_wheel_size/2);
+ const int img_wheel_y = bg_wheel_y-25;
+ float img_wheel_alpha = 0.1f;
+ bool is_engaged = (s->status == STATUS_ENGAGED);
+ bool is_warning = (s->status == STATUS_WARNING);
+ bool is_engageable = scene->engageable;
+ if (is_engaged || is_warning || is_engageable) {
+ nvgBeginPath(s->vg);
+ nvgCircle(s->vg, bg_wheel_x, (bg_wheel_y + (bdr_s*1.5)), bg_wheel_size);
+ if (is_engaged) {
+ nvgFillColor(s->vg, nvgRGBA(23, 134, 68, 255));
+ } else if (is_warning) {
+ nvgFillColor(s->vg, nvgRGBA(218, 111, 37, 255));
+ } else if (is_engageable) {
+ nvgFillColor(s->vg, nvgRGBA(23, 51, 73, 255));
+ }
+ nvgFill(s->vg);
+ img_wheel_alpha = 1.0f;
}
+ nvgBeginPath(s->vg);
+ NVGpaint imgPaint = nvgImagePattern(s->vg, img_wheel_x, img_wheel_y,
+ img_wheel_size, img_wheel_size, 0, s->img_wheel, img_wheel_alpha);
+ nvgRect(s->vg, img_wheel_x, img_wheel_y, img_wheel_size, img_wheel_size);
+ nvgFillPaint(s->vg, imgPaint);
nvgFill(s->vg);
- img_wheel_alpha = 1.0f;
}
+}
+
+static void ui_draw_vision_map(UIState *s) {
+ const UIScene *scene = &s->scene;
+ const int map_size = 96;
+ const int map_x = (scene->ui_viz_rx + (map_size * 3) + (bdr_s * 3));
+ const int map_y = (footer_y + ((footer_h - map_size) / 2));
+ const int map_img_size = (map_size * 1.5);
+ const int map_img_x = (map_x - (map_img_size / 2));
+ const int map_img_y = (map_y - (map_size / 4));
+
+ bool map_valid = s->scene.map_valid;
+ float map_img_alpha = map_valid ? 1.0f : 0.15f;
+ float map_bg_alpha = map_valid ? 0.3f : 0.1f;
+ NVGcolor map_bg = nvgRGBA(0, 0, 0, (255 * map_bg_alpha));
+ NVGpaint map_img = nvgImagePattern(s->vg, map_img_x, map_img_y,
+ map_img_size, map_img_size, 0, s->img_map, map_img_alpha);
+
+ nvgBeginPath(s->vg);
+ nvgCircle(s->vg, map_x, (map_y + (bdr_s * 1.5)), map_size);
+ nvgFillColor(s->vg, map_bg);
+ nvgFill(s->vg);
+
nvgBeginPath(s->vg);
- NVGpaint imgPaint = nvgImagePattern(s->vg, img_wheel_x, img_wheel_y,
- img_wheel_size, img_wheel_size, 0, s->img_wheel, img_wheel_alpha);
- nvgRect(s->vg, img_wheel_x, img_wheel_y, img_wheel_size, img_wheel_size);
- nvgFillPaint(s->vg, imgPaint);
+ nvgRect(s->vg, map_img_x, map_img_y, map_img_size, map_img_size);
+ nvgFillPaint(s->vg, map_img);
nvgFill(s->vg);
}
@@ -1217,7 +1297,7 @@ static void ui_draw_vision_header(UIState *s) {
ui_draw_vision_maxspeed(s);
ui_draw_vision_speedlimit(s);
ui_draw_vision_speed(s);
- ui_draw_vision_wheel(s);
+ ui_draw_vision_event(s);
}
static void ui_draw_vision_footer(UIState *s) {
@@ -1228,8 +1308,8 @@ static void ui_draw_vision_footer(UIState *s) {
nvgBeginPath(s->vg);
nvgRect(s->vg, ui_viz_rx, footer_y, ui_viz_rw, footer_h);
- // Driver Monitoring
ui_draw_vision_face(s);
+ ui_draw_vision_map(s);
}
static void ui_draw_vision_alert(UIState *s, int va_size, int va_color,
@@ -1624,6 +1704,9 @@ static void ui_update(UIState *s) {
s->scene.frontview = datad.rearViewCam;
+ s->scene.v_curvature = datad.vCurvature;
+ s->scene.decel_for_turn = datad.decelForTurn;
+
if (datad.alertSound.str && datad.alertSound.str[0] != '\0' && strcmp(s->alert_type, datad.alertType.str) != 0) {
char* error = NULL;
if (s->alert_sound[0] != '\0') {
@@ -1788,6 +1871,7 @@ static void ui_update(UIState *s) {
cereal_read_LiveMapData(&datad, eventd.liveMapData);
s->scene.speedlimit = datad.speedLimit;
s->scene.speedlimit_valid = datad.speedLimitValid;
+ s->scene.map_valid = datad.mapValid;
}
capn_free(&ctx);
zmq_msg_close(&msg);
@@ -2064,6 +2148,12 @@ int main() {
read_is_metric(s);
}
+ if (s->limit_set_speed_timeout > 0) {
+ s->limit_set_speed_timeout--;
+ } else {
+ read_limit_set_speed(s);
+ }
+
pthread_mutex_unlock(&s->lock);
// the bg thread needs to be scheduled, so the main thread needs time without the lock
diff --git a/selfdrive/visiond/LICENSE.boringssl b/selfdrive/visiond/LICENSE.boringssl
index a25996f7202450..0b0b9b3292837f 100644
--- a/selfdrive/visiond/LICENSE.boringssl
+++ b/selfdrive/visiond/LICENSE.boringssl
@@ -32,7 +32,7 @@ record keeping.)
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -87,21 +87,21 @@ record keeping.)
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -116,10 +116,10 @@ record keeping.)
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -131,7 +131,7 @@ record keeping.)
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
diff --git a/selfdrive/visiond/README b/selfdrive/visiond/README
index d237562739bcd0..1b612afcece0ed 100644
--- a/selfdrive/visiond/README
+++ b/selfdrive/visiond/README
@@ -1,3 +1 @@
visiond runs the openpilot/chffrplus vision pipeline. Everything running between the camera hardware and model outputs lives here.
-
-Contact us if you'd like features added or support for your platform.
diff --git a/selfdrive/visiond/SConscript b/selfdrive/visiond/SConscript
new file mode 100644
index 00000000000000..e55fbd94d9a63e
--- /dev/null
+++ b/selfdrive/visiond/SConscript
@@ -0,0 +1,17 @@
+Import('env')
+lenv = env.Clone()
+lenv['CPPPATH'] += ['include']
+lenv['LIBPATH'] += ['/system/vendor/lib64']
+lenv['CFLAGS'] += ' -DQCOM'
+lenv['CXXFLAGS'] += ' -DQCOM -U __ANDROID__'
+lenv.Program(['visiond.cc', 'model.c', 'transform.c', 'loadyuv.c', 'buffering.c', 'efd.c',
+ 'yuvmodel.c', 'temporalmodel.c', 'monitoring.c', 'monitoringmodel.c', 'clutil.c',
+ 'camera_qcom.c', 'visionbuf_ion.c'],
+ LIBS=['zmq', 'czmq', 'capnp', 'capnp_c', 'kj', 'yaml-cpp', 'z', 'curl',
+ 'gsl', 'CB', 'OpenCL',
+ 'opencv_video', 'opencv_imgproc', 'opencv_core',
+ 'gnustl_shared', 'log', 'cutils',
+ 'yuv',
+ 'common', 'cereal',
+ ])
+
diff --git a/selfdrive/visiond/__init__.py b/selfdrive/visiond/__init__.py
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/selfdrive/visiond/bufs.h b/selfdrive/visiond/bufs.h
new file mode 100644
index 00000000000000..71930baede2cfe
--- /dev/null
+++ b/selfdrive/visiond/bufs.h
@@ -0,0 +1,8 @@
+#ifndef _SELFDRIVE_VISIOND_VISIOND_H_
+#define _SELFDRIVE_VISIOND_VISIOND_H_
+
+#include
+
+typedef struct { uint8_t *y, *u, *v; } YUVBuf;
+
+#endif // _SELFDRIVE_VISIOND_VISIOND_H_
diff --git a/selfdrive/visiond/build_from_src.mk b/selfdrive/visiond/build_from_src.mk
new file mode 100644
index 00000000000000..efa151d1d248ef
--- /dev/null
+++ b/selfdrive/visiond/build_from_src.mk
@@ -0,0 +1,227 @@
+CC = clang
+CXX = clang++
+
+BASEDIR = ../..
+EXTERNAL = ../../external
+PHONELIBS = ../../phonelibs
+
+WARN_FLAGS = -Werror=implicit-function-declaration \
+ -Werror=incompatible-pointer-types \
+ -Werror=int-conversion \
+ -Werror=return-type \
+ -Werror=format-extra-args \
+ -Wno-deprecated-declarations
+
+CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS)
+CXXFLAGS = -std=c++14 -fPIC -O2 $(WARN_FLAGS)
+
+#ifneq ($(RELEASE),1)
+#CFLAGS += -g
+#CXXFLAGS += -g
+#endif
+
+JSON_FLAGS = -I$(PHONELIBS)/json/src
+JSON11_FLAGS = -I$(PHONELIBS)/json11/
+EIGEN_FLAGS = -I$(PHONELIBS)/eigen
+
+UNAME_M := $(shell uname -m)
+UNAME_S := $(shell uname -s)
+
+ifeq ($(UNAME_M),x86_64)
+
+ifeq ($(UNAME_S),Darwin)
+ LIBYUV_FLAGS = -I$(PHONELIBS)/libyuv/include
+ LIBYUV_LIBS = $(PHONELIBS)/libyuv/mac/lib/libyuv.a
+
+ ZMQ_FLAGS = -I$(EXTERNAL)/zmq/include
+ ZMQ_LIBS = $(PHONELIBS)/zmq/mac/lib/libczmq.a \
+ $(PHONELIBS)/zmq/mac/lib/libzmq.a
+
+ OPENCL_LIBS = -framework OpenCL
+else
+ LIBYUV_FLAGS = -I$(PHONELIBS)/libyuv/x64/include
+ LIBYUV_LIBS = $(PHONELIBS)/libyuv/x64/lib/libyuv.a
+
+ ZMQ_FLAGS = -I$(EXTERNAL)/zmq/include
+ ZMQ_LIBS = -L$(EXTERNAL)/zmq/lib \
+ -l:libczmq.a -l:libzmq.a
+
+ OPENCL_LIBS = -lOpenCL
+endif
+
+ CURL_FLAGS = -I/usr/include/curl
+ CURL_LIBS = -lcurl -lz
+
+ SSL_FLAGS = -I/usr/include/openssl/
+ SSL_LIBS = -lssl -lcrypto
+
+ OPENCV_FLAGS =
+ OPENCV_LIBS = -lopencv_video \
+ -lopencv_imgproc \
+ -lopencv_core
+ OTHER_LIBS = -lz -lm -lpthread
+
+ PLATFORM_OBJS = camera_fake.o \
+ ../common/visionbuf_cl.o
+
+ CFLAGS += -D_GNU_SOURCE \
+ -DCLU_NO_CACHE
+else
+ # assume phone
+
+ LIBYUV_FLAGS = -I$(PHONELIBS)/libyuv/include
+ LIBYUV_LIBS = $(PHONELIBS)/libyuv/lib/libyuv.a
+
+ ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include
+ ZMQ_LIBS = -L$(PHONELIBS)/zmq/aarch64/lib \
+ -l:libczmq.a -l:libzmq.a \
+ -lgnustl_shared
+
+ CURL_FLAGS = -I$(PHONELIBS)/curl/include
+ CURL_LIBS = $(PHONELIBS)/curl/lib/libcurl.a \
+ $(PHONELIBS)/zlib/lib/libz.a
+
+ SSL_FLAGS = -I$(PHONELIBS)/boringssl/include
+ SSL_LIBS = $(PHONELIBS)/boringssl/lib/libssl_static.a \
+ $(PHONELIBS)/boringssl/lib/libcrypto_static.a
+
+ OPENCL_FLAGS = -I$(PHONELIBS)/opencl/include
+ OPENCL_LIBS = -lgsl -lCB -lOpenCL
+
+ OPENCV_FLAGS = -I/usr/local/sdk/native/jni/include
+ OPENCV_LIBS = -L/usr/local/sdk/native/libs \
+ -l:libopencv_video.a \
+ -l:libopencv_imgproc.a \
+ -l:libopencv_core.a
+
+ OPENGL_LIBS = -lGLESv3 -lEGL
+
+ SNPE_FLAGS = -I$(PHONELIBS)/snpe/include/
+ SNPE_LIBS = -L$(PHONELIBS)/snpe/lib -lSNPE -lsymphony-cpu -lsymphonypower
+
+ OTHER_LIBS = -lz -lcutils -lm -llog -lui -ladreno_utils
+
+ PLATFORM_OBJS = camera_qcom.o \
+ ../common/visionbuf_ion.o
+
+ CFLAGS += -DQCOM
+ CXXFLAGS += -DQCOM
+endif
+
+OBJS = visiond.o
+OUTPUT = visiond
+
+.PHONY: all
+all: $(OUTPUT)
+
+include ../common/cereal.mk
+
+OBJS += $(PLATFORM_OBJS) \
+ ../common/swaglog.o \
+ ../common/ipc.o \
+ ../common/visionipc.o \
+ ../common/visionimg.o \
+ ../common/util.o \
+ ../common/params.o \
+ ../common/efd.o \
+ ../common/buffering.o \
+ transform.o \
+ loadyuv.o \
+ commonmodel.o \
+ snpemodel.o \
+ monitoring.o \
+ model.o \
+ clutil.o \
+ $(PHONELIBS)/json/src/json.o \
+ $(PHONELIBS)/json11/json11.o \
+ $(CEREAL_OBJS)
+
+#MODEL_DATA = ../../models/driving_bigmodel.dlc ../../models/monitoring_model.dlc
+MODEL_DATA = ../../models/driving_model.dlc ../../models/monitoring_model.dlc
+MODEL_OBJS = $(MODEL_DATA:.dlc=.o)
+OBJS += $(MODEL_OBJS)
+
+ifeq ($(RELEASE),1)
+CFLAGS += -DCLU_NO_SRC
+CXXFLAGS += -DCLU_NO_SRC
+CLCACHE_FILES = $(wildcard /tmp/clcache/*.clb)
+CLCACHE_OBJS += $(CLCACHE_FILES:.clb=.o)
+OBJS += $(CLCACHE_OBJS)
+
+clutil.o: clcache_bins.h
+clcache_bins.h: $(CLCACHE_FILES) /tmp/clcache/index.cli
+ rm -f '$@'
+ for hash in $(basename $(notdir $(CLCACHE_FILES))) ; do \
+ echo "extern const uint8_t clb_$$hash[] asm(\"_binary_$${hash}_clb_start\");" ; \
+ echo "extern const uint8_t clb_$${hash}_end[] asm(\"_binary_$${hash}_clb_end\");" ; \
+ done >> '$@'
+ echo "static const CLUProgramIndex clu_index[] = {" >> '$@'
+ while read idx_hash code_hash; do \
+ echo "{ 0x$$idx_hash, clb_$${code_hash}, clb_$${code_hash}_end }," ; \
+ done < /tmp/clcache/index.cli >> '$@'
+ echo "};" >> '$@'
+
+$(CLCACHE_OBJS): %.o: %.clb
+ @echo "[ bin2o ] $@"
+ cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)'
+
+LDFLAGS += -s
+endif
+
+DEPS := $(OBJS:.o=.d)
+
+$(OUTPUT): $(OBJS)
+ @echo "[ LINK ] $@"
+ $(CXX) -fPIC -o '$@' $^ \
+ $(LDFLAGS) \
+ $(LIBYUV_LIBS) \
+ $(OPENCV_LIBS) \
+ $(OPENGL_LIBS) \
+ $(CEREAL_LIBS) \
+ $(ZMQ_LIBS) \
+ -L/usr/lib \
+ -L/system/vendor/lib64 \
+ $(OPENCL_LIBS) \
+ $(CURL_LIBS) \
+ $(SSL_LIBS) \
+ $(SNPE_LIBS) \
+ $(OTHER_LIBS)
+
+$(MODEL_OBJS): %.o: %.dlc
+ @echo "[ bin2o ] $@"
+ cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)'
+
+%.o: %.cc
+ @echo "[ CXX ] $@"
+ $(CXX) $(CXXFLAGS) -MMD \
+ -Iinclude -I.. -I../.. \
+ $(OPENCV_FLAGS) $(EIGEN_FLAGS) \
+ $(ZMQ_FLAGS) \
+ $(CEREAL_CXXFLAGS) \
+ $(OPENCL_FLAGS) \
+ $(LIBYUV_FLAGS) \
+ $(SNPE_FLAGS) \
+ $(JSON_FLAGS) \
+ $(JSON11_FLAGS) $(CURL_FLAGS) \
+ -I$(PHONELIBS)/libgralloc/include \
+ -I$(PHONELIBS)/linux/include \
+ -c -o '$@' '$<'
+
+%.o: %.c
+ @echo "[ CC ] $@"
+ $(CC) $(CFLAGS) -MMD \
+ -Iinclude -I.. -I../.. \
+ $(ZMQ_FLAGS) \
+ $(CEREAL_CFLAGS) \
+ $(OPENCL_FLAGS) \
+ $(LIBYUV_FLAGS) \
+ $(JSON_FLAGS) \
+ -I$(PHONELIBS)/libgralloc/include \
+ -I$(PHONELIBS)/linux/include \
+ -c -o '$@' '$<'
+
+.PHONY: clean
+clean:
+ rm -f visiond $(OBJS) $(DEPS)
+
+-include $(DEPS)
diff --git a/selfdrive/visiond/camera_common.h b/selfdrive/visiond/camera_common.h
new file mode 100644
index 00000000000000..cea6a9d125d3cd
--- /dev/null
+++ b/selfdrive/visiond/camera_common.h
@@ -0,0 +1,46 @@
+#ifndef CAMERA_COMMON_H
+#define CAMERA_COMMON_H
+
+#include
+#include
+
+#define CAMERA_ID_IMX298 0
+#define CAMERA_ID_IMX179 1
+#define CAMERA_ID_S5K3P8SP 2
+#define CAMERA_ID_OV8865 3
+#define CAMERA_ID_IMX298_FLIPPED 4
+#define CAMERA_ID_OV10640 5
+#define CAMERA_ID_MAX 6
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct CameraInfo {
+ const char* name;
+ int frame_width, frame_height;
+ int frame_stride;
+ bool bayer;
+ int bayer_flip;
+ bool hdr;
+} CameraInfo;
+
+typedef struct FrameMetadata {
+ uint32_t frame_id;
+ uint64_t timestamp_eof;
+ unsigned int frame_length;
+ unsigned int integ_lines;
+ unsigned int global_gain;
+ unsigned int lens_pos;
+ float lens_sag;
+ float lens_err;
+ float lens_true_pos;
+} FrameMetadata;
+
+extern CameraInfo cameras_supported[CAMERA_ID_MAX];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/selfdrive/visiond/camera_fake.cc b/selfdrive/visiond/camera_fake.cc
new file mode 100644
index 00000000000000..5b7c9cb7b92399
--- /dev/null
+++ b/selfdrive/visiond/camera_fake.cc
@@ -0,0 +1,267 @@
+#include "camera_fake.h"
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include "cereal/gen/cpp/log.capnp.h"
+
+#include "common/util.h"
+#include "common/timing.h"
+#include "common/swaglog.h"
+#include "buffering.h"
+
+extern volatile int do_exit;
+
+#define FRAME_WIDTH 1164
+#define FRAME_HEIGHT 874
+
+namespace {
+void camera_open(CameraState *s, VisionBuf *camera_bufs, bool rear) {
+ assert(camera_bufs);
+ s->camera_bufs = camera_bufs;
+}
+
+void camera_close(CameraState *s) {
+ tbuffer_stop(&s->camera_tb);
+}
+
+void camera_release_buffer(void *cookie, int buf_idx) {
+ CameraState *s = static_cast(cookie);
+}
+
+void camera_init(CameraState *s, int camera_id, unsigned int fps) {
+ assert(camera_id < ARRAYSIZE(cameras_supported));
+ s->ci = cameras_supported[camera_id];
+ assert(s->ci.frame_width != 0);
+
+ s->frame_size = s->ci.frame_height * s->ci.frame_stride;
+ s->fps = fps;
+
+ tbuffer_init2(&s->camera_tb, FRAME_BUF_COUNT, "frame", camera_release_buffer,
+ s);
+}
+
+
+void run_simulator(DualCameraState *s) {
+ int err = 0;
+
+ zsock_t *frame_sock = zsock_new_sub(">tcp://127.0.0.1:9003", "");
+ assert(frame_sock);
+ void *frame_sock_raw = zsock_resolve(frame_sock);
+
+ CameraState *const rear_camera = &s->rear;
+
+ auto *tb = &rear_camera->camera_tb;
+
+ while (!do_exit) {
+ const int buf_idx = tbuffer_select(tb);
+
+ auto *buf = &rear_camera->camera_bufs[buf_idx];
+
+ zmq_msg_t t_msg;
+ err = zmq_msg_init(&t_msg);
+ assert(err == 0);
+
+ zmq_msg_t frame_msg;
+ err = zmq_msg_init(&frame_msg);
+ assert(err == 0);
+
+ // recv multipart (t, frame)
+ err = zmq_msg_recv(&t_msg, frame_sock_raw, 0);
+ assert(err != -1);
+ err = zmq_msg_recv(&frame_msg, frame_sock_raw, 0);
+ assert(err != -1);
+
+ assert(zmq_msg_size(&t_msg) >= 8);
+ uint8_t* dat = (uint8_t*)zmq_msg_data(&t_msg);
+ float t = *(float*)&dat[0];
+ uint32_t frame = *(uint32_t*)&dat[4];
+
+ rear_camera->camera_bufs_metadata[buf_idx] = {
+ .frame_id = frame,
+ .timestamp_eof = nanos_since_boot(),
+ .frame_length = 0,
+ .integ_lines = 0,
+ .global_gain = 0,
+ };
+
+
+ assert(zmq_msg_size(&frame_msg) == rear_camera->frame_size);
+
+ err = libyuv::RAWToRGB24((const uint8_t*)zmq_msg_data(&frame_msg), rear_camera->ci.frame_width*3,
+ (uint8_t*)buf->addr, rear_camera->ci.frame_stride,
+ rear_camera->ci.frame_width, rear_camera->ci.frame_height);
+ assert(err == 0);
+
+ visionbuf_sync(buf, VISIONBUF_SYNC_TO_DEVICE);
+ tbuffer_dispatch(tb, buf_idx);
+
+ err = zmq_msg_close(&frame_msg);
+ assert(err == 0);
+ err = zmq_msg_close(&t_msg);
+ assert(err == 0);
+ }
+
+ zsock_destroy(&frame_sock);
+}
+
+void run_unlogger(DualCameraState *s) {
+ zsock_t *frame_sock = zsock_new_sub(NULL, "");
+ assert(frame_sock);
+ int err = zsock_connect(frame_sock,
+ "ipc:///tmp/9464f05d-9d88-4fc9-aa17-c75352d9590d");
+ assert(err == 0);
+ void *frame_sock_raw = zsock_resolve(frame_sock);
+
+ CameraState *const rear_camera = &s->rear;
+ auto frame_data = std::vector{};
+
+ auto *tb = &rear_camera->camera_tb;
+
+ while (!do_exit) {
+ // Handle rear camera only.
+ zmq_msg_t msg;
+ int rc = zmq_msg_init(&msg);
+ assert(rc == 0);
+ rc = zmq_msg_recv(&msg, frame_sock_raw, 0);
+ if (rc == -1) {
+ if (do_exit) {
+ break;
+ } else {
+ fprintf(stderr, "Could not recv frame message: %d\n", errno);
+ }
+ }
+ assert(rc != -1);
+
+ const size_t msg_size_words = zmq_msg_size(&msg) / sizeof(capnp::word);
+ assert(msg_size_words * sizeof(capnp::word) == zmq_msg_size(&msg));
+
+ if (frame_data.size() < msg_size_words) {
+ frame_data = std::vector{msg_size_words};
+ }
+ std::memcpy(frame_data.data(), zmq_msg_data(&msg),
+ msg_size_words * sizeof(*frame_data.data()));
+ zmq_msg_close(&msg);
+
+ capnp::FlatArrayMessageReader message{
+ kj::arrayPtr(frame_data.data(), msg_size_words), {}};
+
+ const auto &event = message.getRoot();
+ assert(event.which() == cereal::Event::FRAME);
+ const auto reader = event.getFrame();
+ assert(reader.hasImage());
+ const auto yuv_image = reader.getImage();
+
+ // Copy camera data to buffer.
+ const size_t width = rear_camera->ci.frame_width;
+ const size_t height = rear_camera->ci.frame_height;
+
+ const size_t y_len = width * height;
+ const uint8_t *const y = yuv_image.begin();
+ const uint8_t *const u = y + y_len;
+ const uint8_t *const v = u + y_len / 4;
+
+ assert(yuv_image.size() == y_len * 3 / 2);
+
+ const int buf_idx = tbuffer_select(tb);
+ rear_camera->camera_bufs_metadata[buf_idx] = {
+ .frame_id = reader.getFrameId(),
+ .timestamp_eof = reader.getTimestampEof(),
+ .frame_length = static_cast(reader.getFrameLength()),
+ .integ_lines = static_cast(reader.getIntegLines()),
+ .global_gain = static_cast(reader.getGlobalGain()),
+ };
+
+ auto *buf = &rear_camera->camera_bufs[buf_idx];
+ uint8_t *const rgb = static_cast(buf->addr);
+
+ // Convert to RGB.
+ const int result = libyuv::I420ToRGB24(y, width, u, width / 2, v, width / 2,
+ rgb, width * 3, width, height);
+ assert(result == 0);
+
+ visionbuf_sync(buf, VISIONBUF_SYNC_TO_DEVICE);
+
+ // HACK(mgraczyk): Do not drop frames.
+ while (*(volatile int*)&tb->pending_idx != -1) {
+ usleep(20000);
+ }
+ tbuffer_dispatch(tb, buf_idx);
+ }
+
+ zsock_destroy(&frame_sock);
+}
+
+} // namespace
+
+CameraInfo cameras_supported[CAMERA_ID_MAX] = {
+ [CAMERA_ID_IMX298] = {
+ .frame_width = FRAME_WIDTH,
+ .frame_height = FRAME_HEIGHT,
+ .frame_stride = FRAME_WIDTH*3,
+ .bayer = false,
+ .bayer_flip = false,
+ },
+};
+
+void cameras_init(DualCameraState *s) {
+ memset(s, 0, sizeof(*s));
+
+ camera_init(&s->rear, CAMERA_ID_IMX298, 20);
+ camera_init(&s->front, CAMERA_ID_IMX298, 20);
+
+ if (getenv("SIMULATOR2")) {
+ // simulator camera is flipped vertically
+ s->rear.transform = (mat3){{
+ 1.0, 0.0, 0.0,
+ 0.0, -1.0, s->rear.ci.frame_height - 1.0f,
+ 0.0, 0.0, 1.0,
+ }};
+ } else {
+ // assume the input is upside-down
+ s->rear.transform = (mat3){{
+ -1.0, 0.0, s->rear.ci.frame_width - 1.0f,
+ 0.0, -1.0, s->rear.ci.frame_height - 1.0f,
+ 0.0, 0.0, 1.0,
+ }};
+ }
+}
+
+void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear,
+ VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats,
+ VisionBuf *camera_bufs_front) {
+ assert(camera_bufs_rear);
+ assert(camera_bufs_front);
+ int err;
+
+ // LOG("*** open front ***");
+ camera_open(&s->front, camera_bufs_front, false);
+
+ // LOG("*** open rear ***");
+ camera_open(&s->rear, camera_bufs_rear, true);
+}
+
+void cameras_close(DualCameraState *s) {
+ camera_close(&s->rear);
+ camera_close(&s->front);
+}
+
+void camera_autoexposure(CameraState *s, float grey_frac) {}
+
+
+void cameras_run(DualCameraState *s) {
+ set_thread_name("fake_camera");
+
+ if (getenv("SIMULATOR2")) {
+ run_simulator(s);
+ } else {
+ run_unlogger(s);
+ }
+
+ cameras_close(s);
+
+}
diff --git a/selfdrive/visiond/camera_fake.h b/selfdrive/visiond/camera_fake.h
new file mode 100644
index 00000000000000..04ad01a6d06ef7
--- /dev/null
+++ b/selfdrive/visiond/camera_fake.h
@@ -0,0 +1,52 @@
+#ifndef FAKE_CAMERA_H
+#define FAKE_CAMERA_H
+
+#include
+
+#include "common/mat.h"
+
+#include "buffering.h"
+#include "common/visionbuf.h"
+#include "camera_common.h"
+
+#define FRAME_BUF_COUNT 4
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct CameraState {
+ int camera_id;
+ CameraInfo ci;
+ int frame_size;
+
+ VisionBuf *camera_bufs;
+ FrameMetadata camera_bufs_metadata[FRAME_BUF_COUNT];
+ TBuffer camera_tb;
+
+ int fps;
+ float digital_gain;
+
+ mat3 transform;
+} CameraState;
+
+
+typedef struct DualCameraState {
+ int ispif_fd;
+
+ CameraState rear;
+ CameraState front;
+} DualCameraState;
+
+void cameras_init(DualCameraState *s);
+void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front);
+void cameras_run(DualCameraState *s);
+void cameras_close(DualCameraState *s);
+
+void camera_autoexposure(CameraState *s, float grey_frac);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
diff --git a/selfdrive/visiond/camera_qcom.c b/selfdrive/visiond/camera_qcom.c
new file mode 100644
index 00000000000000..08a1dff6526e8c
--- /dev/null
+++ b/selfdrive/visiond/camera_qcom.c
@@ -0,0 +1,2275 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+
+#include
+#include
+
+#include "msmb_isp.h"
+#include "msmb_ispif.h"
+#include "msmb_camera.h"
+#include "msm_cam_sensor.h"
+
+#include "common/util.h"
+#include "common/timing.h"
+#include "common/swaglog.h"
+#include "common/params.h"
+
+#include "cereal/gen/c/log.capnp.h"
+
+#include "sensor_i2c.h"
+
+#include "camera_qcom.h"
+
+
+// enable this to run the camera at 60fps and sample every third frame
+// supposed to reduce 33ms of lag, but no results
+//#define HIGH_FPS
+
+#define CAMERA_MSG_AUTOEXPOSE 0
+
+typedef struct CameraMsg {
+ int type;
+ int camera_num;
+
+ float grey_frac;
+} CameraMsg;
+
+extern volatile int do_exit;
+
+CameraInfo cameras_supported[CAMERA_ID_MAX] = {
+ [CAMERA_ID_IMX298] = {
+ .frame_width = 2328,
+ .frame_height = 1748,
+ .frame_stride = 2912,
+ .bayer = true,
+ .bayer_flip = 0,
+ .hdr = true
+ },
+ [CAMERA_ID_IMX179] = {
+ .frame_width = 3280,
+ .frame_height = 2464,
+ .frame_stride = 4104,
+ .bayer = true,
+ .bayer_flip = 0,
+ .hdr = false
+ },
+ [CAMERA_ID_S5K3P8SP] = {
+ .frame_width = 2304,
+ .frame_height = 1728,
+ .frame_stride = 2880,
+ .bayer = true,
+ .bayer_flip = 1,
+ .hdr = false
+ },
+ [CAMERA_ID_OV8865] = {
+ .frame_width = 1632,
+ .frame_height = 1224,
+ .frame_stride = 2040, // seems right
+ .bayer = true,
+ .bayer_flip = 3,
+ .hdr = false
+ },
+ // this exists to get the kernel to build for the LeEco in release
+ [CAMERA_ID_IMX298_FLIPPED] = {
+ .frame_width = 2328,
+ .frame_height = 1748,
+ .frame_stride = 2912,
+ .bayer = true,
+ .bayer_flip = 3,
+ .hdr = true
+ },
+ [CAMERA_ID_OV10640] = {
+ .frame_width = 1280,
+ .frame_height = 1080,
+ .frame_stride = 2040,
+ .bayer = true,
+ .bayer_flip = 0,
+ .hdr = true
+ },
+};
+
+static void camera_release_buffer(void* cookie, int buf_idx) {
+ CameraState *s = cookie;
+ // printf("camera_release_buffer %d\n", buf_idx);
+ s->ss[0].qbuf_info[buf_idx].dirty_buf = 1;
+ ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &s->ss[0].qbuf_info[buf_idx]);
+}
+
+static void camera_init(CameraState *s, int camera_id, int camera_num,
+ uint32_t pixel_clock, uint32_t line_length_pclk,
+ unsigned int max_gain, unsigned int fps) {
+ memset(s, 0, sizeof(*s));
+
+ s->camera_num = camera_num;
+ s->camera_id = camera_id;
+
+ assert(camera_id < ARRAYSIZE(cameras_supported));
+ s->ci = cameras_supported[camera_id];
+ assert(s->ci.frame_width != 0);
+ s->frame_size = s->ci.frame_height * s->ci.frame_stride;
+
+ s->pixel_clock = pixel_clock;
+ s->line_length_pclk = line_length_pclk;
+ s->max_gain = max_gain;
+ s->fps = fps;
+
+ zsock_t *ops_sock = zsock_new_push(">inproc://cameraops");
+ assert(ops_sock);
+ s->ops_sock = zsock_resolve(ops_sock);
+
+ tbuffer_init2(&s->camera_tb, FRAME_BUF_COUNT, "frame",
+ camera_release_buffer, s);
+
+ pthread_mutex_init(&s->frame_info_lock, NULL);
+}
+
+
+int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type) {
+ struct msm_camera_i2c_reg_setting out_settings = {
+ .reg_setting = arr,
+ .size = size,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .data_type = data_type,
+ .delay = 0,
+ };
+ struct sensorb_cfg_data cfg_data = {0};
+ cfg_data.cfgtype = CFG_WRITE_I2C_ARRAY;
+ cfg_data.cfg.setting = &out_settings;
+ return ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &cfg_data);
+}
+
+static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) {
+ int err;
+
+ int analog_gain = min(gain, 448);
+
+ if (gain > 448) {
+ s->digital_gain = (512.0/(512-(gain))) / 8.0;
+ } else {
+ s->digital_gain = 1.0;
+ }
+
+ //printf("%5d/%5d %5d %f\n", s->cur_integ_lines, s->cur_frame_length, analog_gain, s->digital_gain);
+
+ int digital_gain = 0x100;
+
+ float white_balance[] = {0.4609375, 1.0, 0.546875};
+ //float white_balance[] = {1.0, 1.0, 1.0};
+
+ int digital_gain_gr = digital_gain / white_balance[1];
+ int digital_gain_gb = digital_gain / white_balance[1];
+ int digital_gain_r = digital_gain / white_balance[0];
+ int digital_gain_b = digital_gain / white_balance[2];
+
+ struct msm_camera_i2c_reg_array reg_array[] = {
+ // REG_HOLD
+ {0x104,0x1,0},
+ {0x3002,0x0,0}, // long autoexposure off
+
+ // FRM_LENGTH
+ {0x340, frame_length >> 8, 0}, {0x341, frame_length & 0xff, 0},
+ // INTEG_TIME aka coarse_int_time_addr aka shutter speed
+ {0x202, integ_lines >> 8, 0}, {0x203, integ_lines & 0xff,0},
+ // global_gain_addr
+ // if you assume 1x gain is 32, 448 is 14x gain, aka 2^14=16384
+ {0x204, analog_gain >> 8, 0}, {0x205, analog_gain & 0xff,0},
+
+ // digital gain for colors: gain_greenR, gain_red, gain_blue, gain_greenB
+ /*{0x20e, digital_gain_gr >> 8, 0}, {0x20f,digital_gain_gr & 0xFF,0},
+ {0x210, digital_gain_r >> 8, 0}, {0x211,digital_gain_r & 0xFF,0},
+ {0x212, digital_gain_b >> 8, 0}, {0x213,digital_gain_b & 0xFF,0},
+ {0x214, digital_gain_gb >> 8, 0}, {0x215,digital_gain_gb & 0xFF,0},*/
+
+ // REG_HOLD
+ {0x104,0x0,0},
+ };
+
+ err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA);
+ if (err != 0) {
+ LOGE("apply_exposure err %d", err);
+ }
+ return err;
+}
+
+static inline int ov8865_get_coarse_gain(int gain) {
+ static const int gains[] = {0, 256, 384, 448, 480};
+ int i;
+
+ for (i = 1; i < ARRAYSIZE(gains); i++) {
+ if (gain >= gains[i - 1] && gain < gains[i])
+ break;
+ }
+
+ return i - 1;
+}
+
+static int ov8865_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) {
+ //printf("front camera: %d %d %d\n", gain, integ_lines, frame_length);
+ int err, gain_bitmap;
+ gain_bitmap = (1 << ov8865_get_coarse_gain(gain)) - 1;
+ integ_lines *= 16; // The exposure value in reg is in 16ths of a line
+ struct msm_camera_i2c_reg_array reg_array[] = {
+ //{0x104,0x1,0},
+
+ // FRM_LENGTH
+ {0x380e, frame_length >> 8, 0}, {0x380f, frame_length & 0xff, 0},
+ // AEC EXPO
+ {0x3500, integ_lines >> 16, 0}, {0x3501, integ_lines >> 8, 0}, {0x3502, integ_lines & 0xff,0},
+ // AEC MANUAL
+ {0x3503, 0x4, 0},
+ // AEC GAIN
+ {0x3508, gain_bitmap, 0}, {0x3509, 0xf8, 0},
+
+ //{0x104,0x0,0},
+ };
+ err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA);
+ if (err != 0) {
+ LOGE("apply_exposure err %d", err);
+ }
+ return err;
+}
+
+static int imx179_s5k3p8sp_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) {
+ //printf("front camera: %d %d %d\n", gain, integ_lines, frame_length);
+ int err;
+
+ if (gain > 448) {
+ s->digital_gain = (512.0/(512-(gain))) / 8.0;
+ } else {
+ s->digital_gain = 1.0;
+ }
+
+ struct msm_camera_i2c_reg_array reg_array[] = {
+ {0x104,0x1,0},
+
+ // FRM_LENGTH
+ {0x340, frame_length >> 8, 0}, {0x341, frame_length & 0xff, 0},
+ // coarse_int_time
+ {0x202, integ_lines >> 8, 0}, {0x203, integ_lines & 0xff,0},
+ // global_gain
+ {0x204, gain >> 8, 0}, {0x205, gain & 0xff,0},
+
+ {0x104,0x0,0},
+ };
+ err = sensor_write_regs(s, reg_array, ARRAYSIZE(reg_array), MSM_CAMERA_I2C_BYTE_DATA);
+ if (err != 0) {
+ LOGE("apply_exposure err %d", err);
+ }
+ return err;
+}
+
+void cameras_init(DualCameraState *s) {
+ memset(s, 0, sizeof(*s));
+
+ char project_name[1024] = {0};
+ property_get("ro.boot.project_name", project_name, "");
+
+ char product_name[1024] = {0};
+ property_get("ro.product.name", product_name, "");
+
+ if (strlen(project_name) == 0) {
+ LOGD("LePro 3 op system detected");
+ s->device = DEVICE_LP3;
+
+ // sensor is flipped in LP3
+ // IMAGE_ORIENT = 3
+ init_array_imx298[0].reg_data = 3;
+ cameras_supported[CAMERA_ID_IMX298].bayer_flip = 3;
+ } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") != 0) {
+ // no more OP3 support
+ s->device = DEVICE_OP3;
+ assert(false);
+ } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") == 0) {
+ // only OP3T support
+ s->device = DEVICE_OP3T;
+ } else if (strcmp(product_name, "LePro3") == 0) {
+ LOGD("LePro 3 detected");
+ s->device = DEVICE_LP3;
+ assert(false);
+ } else {
+ assert(false);
+ }
+
+ // 0 = ISO 100
+ // 256 = ISO 200
+ // 384 = ISO 400
+ // 448 = ISO 800
+ // 480 = ISO 1600
+ // 496 = ISO 3200
+ // 504 = ISO 6400, 8x digital gain
+ // 508 = ISO 12800, 16x digital gain
+ // 510 = ISO 25600, 32x digital gain
+
+ camera_init(&s->rear, CAMERA_ID_IMX298, 0,
+ /*pixel_clock=*/600000000, /*line_length_pclk=*/5536,
+ /*max_gain=*/510, //0 (ISO 100)- 448 (ISO 800, max analog gain) - 511 (super noisy)
+#ifdef HIGH_FPS
+ /*fps*/60
+#else
+ /*fps*/20
+#endif
+ );
+ s->rear.apply_exposure = imx298_apply_exposure;
+
+ if (s->device == DEVICE_OP3T) {
+ camera_init(&s->front, CAMERA_ID_S5K3P8SP, 1,
+ /*pixel_clock=*/561000000, /*line_length_pclk=*/5120,
+ /*max_gain=*/510, 10);
+ s->front.apply_exposure = imx179_s5k3p8sp_apply_exposure;
+ } else if (s->device == DEVICE_LP3) {
+ camera_init(&s->front, CAMERA_ID_OV8865, 1,
+ /*pixel_clock=*/251200000, /*line_length_pclk=*/7000,
+ /*max_gain=*/510, 10);
+ s->front.apply_exposure = ov8865_apply_exposure;
+ } else {
+ camera_init(&s->front, CAMERA_ID_IMX179, 1,
+ /*pixel_clock=*/251200000, /*line_length_pclk=*/3440,
+ /*max_gain=*/224, 20);
+ s->front.apply_exposure = imx179_s5k3p8sp_apply_exposure;
+ }
+
+ // assume the device is upside-down (not anymore)
+ s->rear.transform = (mat3){{
+ 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0,
+ }};
+
+ // probably wrong
+ s->front.transform = (mat3){{
+ 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0,
+ }};
+
+ s->rear.device = s->device;
+ s->front.device = s->device;
+}
+
+static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) {
+ int err = 0;
+
+ unsigned int frame_length = s->pixel_clock / s->line_length_pclk / s->fps;
+
+ unsigned int gain = s->cur_gain;
+ unsigned int integ_lines = s->cur_integ_lines;
+
+ if (exposure_frac >= 0) {
+ exposure_frac = clamp(exposure_frac, 2.0 / frame_length, 1.0);
+ integ_lines = frame_length * exposure_frac;
+
+ // See page 79 of the datasheet, this is the max allowed (-1 for phase adjust)
+ integ_lines = min(integ_lines, frame_length-11);
+ }
+
+ // done after exposure to not adjust it
+ if (s->using_pll) {
+ // can adjust frame length by up to +/- 1
+ const int PHASE_DEADZONE = 20000; // 20 us
+ int phase_max = 1000000000 / s->fps;
+ int phase_diff = s->phase_actual - s->phase_request;
+ phase_diff = ((phase_diff + phase_max/2) % phase_max) - phase_max/2;
+
+ if (phase_diff < -PHASE_DEADZONE) {
+ frame_length += 1;
+ } else if (phase_diff > PHASE_DEADZONE) {
+ frame_length -= 1;
+ }
+ }
+
+ if (gain_frac >= 0) {
+ // ISO200 is minimum gain
+ gain_frac = clamp(gain_frac, 1.0/64, 1.0);
+
+ // linearize gain response
+ // TODO: will be wrong for front camera
+ // 0.125 -> 448
+ // 0.25 -> 480
+ // 0.5 -> 496
+ // 1.0 -> 504
+ // 512 - 512/(128*gain_frac)
+ gain = (s->max_gain/510) * (512 - 512/(256*gain_frac));
+ }
+
+ if (gain != s->cur_gain
+ || integ_lines != s->cur_integ_lines
+ || frame_length != s->cur_frame_length) {
+
+ if (s->apply_exposure) {
+ err = s->apply_exposure(s, gain, integ_lines, frame_length);
+ }
+
+ if (err == 0) {
+ pthread_mutex_lock(&s->frame_info_lock);
+ s->cur_gain = gain;
+ s->cur_integ_lines = integ_lines;
+ s->cur_frame_length = frame_length;
+ pthread_mutex_unlock(&s->frame_info_lock);
+ }
+ }
+
+ if (err == 0) {
+ s->cur_exposure_frac = exposure_frac;
+ s->cur_gain_frac = gain_frac;
+ }
+
+ LOGD("set exposure: %f %f - %d", exposure_frac, gain_frac, err);
+}
+
+static void do_autoexposure(CameraState *s, float grey_frac) {
+ const float target_grey = 0.3;
+
+ float new_exposure = s->cur_exposure_frac;
+ new_exposure *= pow(1.05, (target_grey - grey_frac) / 0.05 );
+ LOGD("diff %f: %f to %f", target_grey - grey_frac, s->cur_exposure_frac, new_exposure);
+
+ float new_gain = s->cur_gain_frac;
+ if (new_exposure < 0.10) {
+ new_gain *= 0.95;
+ } else if (new_exposure > 0.40) {
+ new_gain *= 1.05;
+ }
+
+ set_exposure(s, new_exposure, new_gain);
+}
+
+void camera_autoexposure(CameraState *s, float grey_frac) {
+ CameraMsg msg = {
+ .type = CAMERA_MSG_AUTOEXPOSE,
+ .camera_num = s->camera_num,
+ .grey_frac = grey_frac,
+ };
+
+ zmq_send(s->ops_sock, &msg, sizeof(msg), ZMQ_DONTWAIT);
+}
+
+static uint8_t* get_eeprom(int eeprom_fd, size_t *out_len) {
+ int err;
+
+ struct msm_eeprom_cfg_data cfg = {0};
+ cfg.cfgtype = CFG_EEPROM_GET_CAL_DATA;
+ err = ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg);
+ assert(err >= 0);
+
+ uint32_t num_bytes = cfg.cfg.get_data.num_bytes;
+ assert(num_bytes > 100);
+
+ uint8_t* buffer = malloc(num_bytes);
+ assert(buffer);
+ memset(buffer, 0, num_bytes);
+
+ cfg.cfgtype = CFG_EEPROM_READ_CAL_DATA;
+ cfg.cfg.read_data.num_bytes = num_bytes;
+ cfg.cfg.read_data.dbuffer = buffer;
+ err = ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg);
+ assert(err >= 0);
+
+ *out_len = num_bytes;
+ return buffer;
+}
+
+static void imx298_ois_calibration(int ois_fd, uint8_t* eeprom) {
+ int err;
+
+ const int ois_registers[][2] = {
+ // == SET_FADJ_PARAM() == (factory adjustment)
+
+ // Set Hall Current DAC
+ {0x8230, *(uint16_t*)(eeprom+0x102)}, //_P_30_ADC_CH0 (CURDAT)
+
+ // Set Hall PreAmp Offset
+ {0x8231, *(uint16_t*)(eeprom+0x104)}, //_P_31_ADC_CH1 (HALOFS_X)
+ {0x8232, *(uint16_t*)(eeprom+0x106)}, //_P_32_ADC_CH2 (HALOFS_Y)
+
+ // Set Hall-X/Y PostAmp Offset
+ {0x841e, *(uint16_t*)(eeprom+0x108)}, //_M_X_H_ofs
+ {0x849e, *(uint16_t*)(eeprom+0x10a)}, //_M_Y_H_ofs
+
+ // Set Residual Offset
+ {0x8239, *(uint16_t*)(eeprom+0x10c)}, //_P_39_Ch3_VAL_1 (PSTXOF)
+ {0x823b, *(uint16_t*)(eeprom+0x10e)}, //_P_3B_Ch3_VAL_3 (PSTYOF)
+
+ // DIGITAL GYRO OFFSET
+ {0x8406, *(uint16_t*)(eeprom+0x110)}, //_M_Kgx00
+ {0x8486, *(uint16_t*)(eeprom+0x112)}, //_M_Kgy00
+ {0x846a, *(uint16_t*)(eeprom+0x120)}, //_M_TMP_X_
+ {0x846b, *(uint16_t*)(eeprom+0x122)}, //_M_TMP_Y_
+
+ // HALLSENSE
+ // Set Hall Gain
+ {0x8446, *(uint16_t*)(eeprom+0x114)}, //_M_KgxHG
+ {0x84c6, *(uint16_t*)(eeprom+0x116)}, //_M_KgyHG
+ // Set Cross Talk Canceller
+ {0x8470, *(uint16_t*)(eeprom+0x124)}, //_M_KgxH0
+ {0x8472, *(uint16_t*)(eeprom+0x126)}, //_M_KgyH0
+
+ // LOOPGAIN
+ {0x840f, *(uint16_t*)(eeprom+0x118)}, //_M_KgxG
+ {0x848f, *(uint16_t*)(eeprom+0x11a)}, //_M_KgyG
+
+ // Position Servo ON ( OIS OFF )
+ {0x847f, 0x0c0c}, //_M_EQCTL
+ };
+
+
+ struct msm_ois_cfg_data cfg = {0};
+ struct msm_camera_i2c_seq_reg_array ois_reg_settings[ARRAYSIZE(ois_registers)] = {{0}};
+ for (int i=0; i> 8) & 0xff;
+ ois_reg_settings[i].reg_data_size = 2;
+ }
+ struct msm_camera_i2c_seq_reg_setting ois_reg_setting = {
+ .reg_setting = &ois_reg_settings[0],
+ .size = ARRAYSIZE(ois_reg_settings),
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .delay = 0,
+ };
+ cfg.cfgtype = CFG_OIS_I2C_WRITE_SEQ_TABLE;
+ cfg.cfg.settings = &ois_reg_setting;
+ err = ioctl(ois_fd, VIDIOC_MSM_OIS_CFG, &cfg);
+ LOG("ois reg calibration: %d", err);
+}
+
+
+
+
+static void sensors_init(DualCameraState *s) {
+ int err;
+
+ int sensorinit_fd = -1;
+ if (s->device == DEVICE_LP3) {
+ sensorinit_fd = open("/dev/v4l-subdev11", O_RDWR | O_NONBLOCK);
+ } else {
+ sensorinit_fd = open("/dev/v4l-subdev12", O_RDWR | O_NONBLOCK);
+ }
+ assert(sensorinit_fd >= 0);
+
+ struct sensor_init_cfg_data sensor_init_cfg = {0};
+
+ // init rear sensor
+
+ struct msm_camera_sensor_slave_info slave_info = {0};
+ if (s->device == DEVICE_LP3) {
+ slave_info = (struct msm_camera_sensor_slave_info){
+ .sensor_name = "imx298",
+ .eeprom_name = "sony_imx298",
+ .actuator_name = "dw9800w",
+ .ois_name = "",
+ .flash_name = "pmic",
+ .camera_id = 0,
+ .slave_addr = 32,
+ .i2c_freq_mode = 1,
+ .addr_type = 2,
+ .sensor_id_info = {
+ .sensor_id_reg_addr = 22,
+ .sensor_id = 664,
+ .sensor_id_mask = 0,
+ .module_id = 9,
+ .vcm_id = 6,
+ },
+ .power_setting_array = {
+ .power_setting_a = {
+ {
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 1,
+ .seq_val = 5,
+ .config_val = 2,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 3,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 24000000,
+ .delay = 1,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 2,
+ .delay = 10,
+ },
+ },
+ .size = 7,
+ .power_down_setting_a = {
+ {
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 1,
+ .seq_val = 5,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 3,
+ .config_val = 0,
+ .delay = 1,
+ },
+ },
+ .size_down = 6,
+ },
+ .is_init_params_valid = 0,
+ .sensor_init_params = {
+ .modes_supported = 1,
+ .position = 0,
+ .sensor_mount_angle = 90,
+ },
+ .output_format = 0,
+ };
+ } else {
+ slave_info = (struct msm_camera_sensor_slave_info){
+ .sensor_name = "imx298",
+ .eeprom_name = "sony_imx298",
+ .actuator_name = "rohm_bu63165gwl",
+ .ois_name = "rohm_bu63165gwl",
+ .camera_id = 0,
+ .slave_addr = 52,
+ .i2c_freq_mode = 2,
+ .addr_type = 2,
+ .sensor_id_info = {
+ .sensor_id_reg_addr = 22,
+ .sensor_id = 664,
+ .sensor_id_mask = 0,
+ },
+ .power_setting_array = {
+ .power_setting_a = {
+ {
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 2,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 2,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 2,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 2,
+ },{
+ .seq_type = 1,
+ .seq_val = 6,
+ .config_val = 2,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 3,
+ .config_val = 0,
+ .delay = 5,
+ },{
+ .seq_type = 2,
+ .seq_val = 4,
+ .config_val = 0,
+ .delay = 5,
+ },{
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 24000000,
+ .delay = 2,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 2,
+ .delay = 2,
+ },
+ },
+ .size = 9,
+ .power_down_setting_a = {
+ {
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 10,
+ },{
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 4,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 3,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 1,
+ .seq_val = 6,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 0,
+ },
+ },
+ .size_down = 8,
+ },
+ .is_init_params_valid = 0,
+ .sensor_init_params = {
+ .modes_supported = 1,
+ .position = 0,
+ .sensor_mount_angle = 360,
+ },
+ .output_format = 0,
+ };
+ }
+ slave_info.power_setting_array.power_setting =
+ (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_setting_a[0];
+ slave_info.power_setting_array.power_down_setting =
+ (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_down_setting_a[0];
+ sensor_init_cfg.cfgtype = CFG_SINIT_PROBE;
+ sensor_init_cfg.cfg.setting = &slave_info;
+ err = ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg);
+ LOG("sensor init cfg (rear): %d", err);
+ assert(err >= 0);
+
+
+ struct msm_camera_sensor_slave_info slave_info2 = {0};
+ if (s->device == DEVICE_LP3) {
+ slave_info2 = (struct msm_camera_sensor_slave_info){
+ .sensor_name = "ov8865_sunny",
+ .eeprom_name = "ov8865_plus",
+ .actuator_name = "",
+ .ois_name = "",
+ .flash_name = "",
+ .camera_id = 2,
+ .slave_addr = 108,
+ .i2c_freq_mode = 1,
+ .addr_type = 2,
+ .sensor_id_info = {
+ .sensor_id_reg_addr = 12299,
+ .sensor_id = 34917,
+ .sensor_id_mask = 0,
+ .module_id = 2,
+ .vcm_id = 0,
+ },
+ .power_setting_array = {
+ .power_setting_a = {
+ {
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 5,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 24000000,
+ .delay = 1,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 2,
+ .delay = 1,
+ },
+ },
+ .size = 6,
+ .power_down_setting_a = {
+ {
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 5,
+ },{
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 1,
+ },
+ },
+ .size_down = 5,
+ },
+ .is_init_params_valid = 0,
+ .sensor_init_params = {
+ .modes_supported = 1,
+ .position = 1,
+ .sensor_mount_angle = 270,
+ },
+ .output_format = 0,
+ };
+ } else if (s->front.camera_id == CAMERA_ID_S5K3P8SP) {
+ // init front camera
+ slave_info2 = (struct msm_camera_sensor_slave_info){
+ .sensor_name = "s5k3p8sp",
+ .eeprom_name = "s5k3p8sp_m24c64s",
+ .actuator_name = "",
+ .ois_name = "",
+ .camera_id = 1,
+ .slave_addr = 32,
+ .i2c_freq_mode = 1,
+ .addr_type = 2,
+ .sensor_id_info = {
+ .sensor_id_reg_addr = 0,
+ .sensor_id = 12552,
+ .sensor_id_mask = 0,
+ },
+ .power_setting_array = {
+ .power_setting_a = {
+ {
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 24000000,
+ .delay = 1,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 2,
+ .delay = 1,
+ },
+ },
+ .size = 6,
+ .power_down_setting_a = {
+ {
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 1,
+ },
+ },
+ .size_down = 5,
+ },
+ .is_init_params_valid = 0,
+ .sensor_init_params = {
+ .modes_supported = 1,
+ .position = 1,
+ .sensor_mount_angle = 270,
+ },
+ .output_format = 0,
+ };
+ } else {
+ // init front camera
+ slave_info2 = (struct msm_camera_sensor_slave_info){
+ .sensor_name = "imx179",
+ .eeprom_name = "sony_imx179",
+ .actuator_name = "",
+ .ois_name = "",
+ .camera_id = 1,
+ .slave_addr = 32,
+ .i2c_freq_mode = 1,
+ .addr_type = 2,
+ .sensor_id_info = {
+ .sensor_id_reg_addr = 2,
+ .sensor_id = 377,
+ .sensor_id_mask = 4095,
+ },
+ .power_setting_array = {
+ .power_setting_a = {
+ {
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 2,
+ .delay = 0,
+ },{
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 24000000,
+ .delay = 0,
+ },
+ },
+ .size = 5,
+ .power_down_setting_a = {
+ {
+ .seq_type = 0,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 1,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 1,
+ },{
+ .seq_type = 2,
+ .seq_val = 0,
+ .config_val = 0,
+ .delay = 2,
+ },{
+ .seq_type = 2,
+ .seq_val = 1,
+ .config_val = 0,
+ .delay = 0,
+ },{
+ .seq_type = 2,
+ .seq_val = 2,
+ .config_val = 0,
+ .delay = 0,
+ },
+ },
+ .size_down = 5,
+ },
+ .is_init_params_valid = 0,
+ .sensor_init_params = {
+ .modes_supported = 1,
+ .position = 1,
+ .sensor_mount_angle = 270,
+ },
+ .output_format = 0,
+ };
+ }
+ slave_info2.power_setting_array.power_setting =
+ (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_setting_a[0];
+ slave_info2.power_setting_array.power_down_setting =
+ (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_down_setting_a[0];
+ sensor_init_cfg.cfgtype = CFG_SINIT_PROBE;
+ sensor_init_cfg.cfg.setting = &slave_info2;
+ err = ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg);
+ LOG("sensor init cfg (front): %d", err);
+ assert(err >= 0);
+}
+
+static void camera_open(CameraState *s, bool rear) {
+ int err;
+
+ struct sensorb_cfg_data sensorb_cfg_data = {0};
+ struct csid_cfg_data csid_cfg_data = {0};
+ struct csiphy_cfg_data csiphy_cfg_data = {0};
+ struct msm_camera_csiphy_params csiphy_params = {0};
+ struct msm_camera_csid_params csid_params = {0};
+ struct msm_vfe_input_cfg input_cfg = {0};
+ struct msm_vfe_axi_stream_update_cmd update_cmd = {0};
+ struct v4l2_event_subscription sub = {0};
+ struct ispif_cfg_data ispif_cfg_data = {0};
+ struct msm_vfe_cfg_cmd_list cfg_cmd_list = {0};
+
+ struct msm_actuator_cfg_data actuator_cfg_data = {0};
+ struct msm_ois_cfg_data ois_cfg_data = {0};
+
+ // open devices
+ if (rear) {
+ s->csid_fd = open("/dev/v4l-subdev3", O_RDWR | O_NONBLOCK);
+ assert(s->csid_fd >= 0);
+ s->csiphy_fd = open("/dev/v4l-subdev0", O_RDWR | O_NONBLOCK);
+ assert(s->csiphy_fd >= 0);
+ if (s->device == DEVICE_LP3) {
+ s->sensor_fd = open("/dev/v4l-subdev17", O_RDWR | O_NONBLOCK);
+ } else {
+ s->sensor_fd = open("/dev/v4l-subdev18", O_RDWR | O_NONBLOCK);
+ }
+ assert(s->sensor_fd >= 0);
+ if (s->device == DEVICE_LP3) {
+ s->isp_fd = open("/dev/v4l-subdev13", O_RDWR | O_NONBLOCK);
+ } else {
+ s->isp_fd = open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK);
+ }
+ assert(s->isp_fd >= 0);
+ s->eeprom_fd = open("/dev/v4l-subdev8", O_RDWR | O_NONBLOCK);
+ assert(s->eeprom_fd >= 0);
+
+ s->actuator_fd = open("/dev/v4l-subdev7", O_RDWR | O_NONBLOCK);
+ assert(s->actuator_fd >= 0);
+
+ if (s->device != DEVICE_LP3) {
+ s->ois_fd = open("/dev/v4l-subdev10", O_RDWR | O_NONBLOCK);
+ assert(s->ois_fd >= 0);
+ }
+ } else {
+ s->csid_fd = open("/dev/v4l-subdev5", O_RDWR | O_NONBLOCK);
+ assert(s->csid_fd >= 0);
+ s->csiphy_fd = open("/dev/v4l-subdev2", O_RDWR | O_NONBLOCK);
+ assert(s->csiphy_fd >= 0);
+ if (s->device == DEVICE_LP3) {
+ s->sensor_fd = open("/dev/v4l-subdev18", O_RDWR | O_NONBLOCK);
+ } else {
+ s->sensor_fd = open("/dev/v4l-subdev19", O_RDWR | O_NONBLOCK);
+ }
+ assert(s->sensor_fd >= 0);
+ if (s->device == DEVICE_LP3) {
+ s->isp_fd = open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK);
+ } else {
+ s->isp_fd = open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK);
+ }
+ assert(s->isp_fd >= 0);
+ s->eeprom_fd = open("/dev/v4l-subdev9", O_RDWR | O_NONBLOCK);
+ assert(s->eeprom_fd >= 0);
+ }
+
+ // *** SHUTDOWN ALL ***
+
+ // CSIPHY: release csiphy
+ struct msm_camera_csi_lane_params csi_lane_params = {0};
+ csi_lane_params.csi_lane_mask = 0x1f;
+ csiphy_cfg_data.cfg.csi_lane_params = &csi_lane_params;
+ csiphy_cfg_data.cfgtype = CSIPHY_RELEASE;
+ err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data);
+ LOG("release csiphy: %d", err);
+
+ // CSID: release csid
+ csid_cfg_data.cfgtype = CSID_RELEASE;
+ err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data);
+ LOG("release csid: %d", err);
+
+ // SENSOR: send power down
+ memset(&sensorb_cfg_data, 0, sizeof(sensorb_cfg_data));
+ sensorb_cfg_data.cfgtype = CFG_POWER_DOWN;
+ err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data);
+ LOG("sensor power down: %d", err);
+
+ if (rear && s->device != DEVICE_LP3) {
+ // ois powerdown
+ ois_cfg_data.cfgtype = CFG_OIS_POWERDOWN;
+ err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data);
+ LOG("ois powerdown: %d", err);
+ }
+
+ // actuator powerdown
+ actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERDOWN;
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data);
+ LOG("actuator powerdown: %d", err);
+
+ // reset isp
+ // struct msm_vfe_axi_halt_cmd halt_cmd = {
+ // .stop_camif = 1,
+ // .overflow_detected = 1,
+ // .blocking_halt = 1,
+ // };
+ // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_HALT, &halt_cmd);
+ // printf("axi halt: %d\n", err);
+
+ // struct msm_vfe_axi_reset_cmd reset_cmd = {
+ // .blocking = 1,
+ // .frame_id = 1,
+ // };
+ // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESET, &reset_cmd);
+ // printf("axi reset: %d\n", err);
+
+ // struct msm_vfe_axi_restart_cmd restart_cmd = {
+ // .enable_camif = 1,
+ // };
+ // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESTART, &restart_cmd);
+ // printf("axi restart: %d\n", err);
+
+ // **** GO GO GO ****
+ LOG("******************** GO GO GO ************************");
+
+ s->eeprom = get_eeprom(s->eeprom_fd, &s->eeprom_size);
+
+ // printf("eeprom:\n");
+ // for (int i=0; ieeprom_size; i++) {
+ // printf("%02x", s->eeprom[i]);
+ // }
+ // printf("\n");
+
+ // CSID: init csid
+ csid_cfg_data.cfgtype = CSID_INIT;
+ err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data);
+ LOG("init csid: %d", err);
+
+ // CSIPHY: init csiphy
+ memset(&csiphy_cfg_data, 0, sizeof(csiphy_cfg_data));
+ csiphy_cfg_data.cfgtype = CSIPHY_INIT;
+ err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data);
+ LOG("init csiphy: %d", err);
+
+ // SENSOR: stop stream
+ struct msm_camera_i2c_reg_setting stop_settings = {
+ .reg_setting = stop_reg_array,
+ .size = ARRAYSIZE(stop_reg_array),
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .data_type = MSM_CAMERA_I2C_BYTE_DATA,
+ .delay = 0
+ };
+ sensorb_cfg_data.cfgtype = CFG_SET_STOP_STREAM_SETTING;
+ sensorb_cfg_data.cfg.setting = &stop_settings;
+ err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data);
+ LOG("stop stream: %d", err);
+
+ // SENSOR: send power up
+ memset(&sensorb_cfg_data, 0, sizeof(sensorb_cfg_data));
+ sensorb_cfg_data.cfgtype = CFG_POWER_UP;
+ err = ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data);
+ LOG("sensor power up: %d", err);
+
+ // **** configure the sensor ****
+
+ // SENSOR: send i2c configuration
+ if (s->camera_id == CAMERA_ID_IMX298) {
+ err = sensor_write_regs(s, init_array_imx298, ARRAYSIZE(init_array_imx298), MSM_CAMERA_I2C_BYTE_DATA);
+ } else if (s->camera_id == CAMERA_ID_S5K3P8SP) {
+ err = sensor_write_regs(s, init_array_s5k3p8sp, ARRAYSIZE(init_array_s5k3p8sp), MSM_CAMERA_I2C_WORD_DATA);
+ } else if (s->camera_id == CAMERA_ID_IMX179) {
+ err = sensor_write_regs(s, init_array_imx179, ARRAYSIZE(init_array_imx179), MSM_CAMERA_I2C_BYTE_DATA);
+ } else if (s->camera_id == CAMERA_ID_OV8865) {
+ err = sensor_write_regs(s, init_array_ov8865, ARRAYSIZE(init_array_ov8865), MSM_CAMERA_I2C_BYTE_DATA);
+ } else {
+ assert(false);
+ }
+ LOG("sensor init i2c: %d", err);
+
+ if (rear) {
+ // init the actuator
+ actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERUP;
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data);
+ LOG("actuator powerup: %d", err);
+
+ actuator_cfg_data.cfgtype = CFG_ACTUATOR_INIT;
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data);
+ LOG("actuator init: %d", err);
+
+
+ // no OIS in LP3
+ if (s->device != DEVICE_LP3) {
+ // see sony_imx298_eeprom_format_afdata in libmmcamera_sony_imx298_eeprom.so
+ const float far_margin = -0.28;
+ uint16_t macro_dac = *(uint16_t*)(s->eeprom + 0x24);
+ s->infinity_dac = *(uint16_t*)(s->eeprom + 0x26);
+ LOG("macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac);
+
+ int dac_range = macro_dac - s->infinity_dac;
+ s->infinity_dac += far_margin * dac_range;
+
+ LOG(" -> macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac);
+
+ struct msm_actuator_reg_params_t actuator_reg_params[] = {
+ {
+ .reg_write_type = MSM_ACTUATOR_WRITE_DAC,
+ .hw_mask = 0,
+ .reg_addr = 240,
+ .hw_shift = 0,
+ .data_type = 10,
+ .addr_type = 4,
+ .reg_data = 0,
+ .delay = 0,
+ }, {
+ .reg_write_type = MSM_ACTUATOR_WRITE_DAC,
+ .hw_mask = 0,
+ .reg_addr = 241,
+ .hw_shift = 0,
+ .data_type = 10,
+ .addr_type = 4,
+ .reg_data = 0,
+ .delay = 0,
+ }, {
+ .reg_write_type = MSM_ACTUATOR_WRITE_DAC,
+ .hw_mask = 0,
+ .reg_addr = 242,
+ .hw_shift = 0,
+ .data_type = 10,
+ .addr_type = 4,
+ .reg_data = 0,
+ .delay = 0,
+ }, {
+ .reg_write_type = MSM_ACTUATOR_WRITE_DAC,
+ .hw_mask = 0,
+ .reg_addr = 243,
+ .hw_shift = 0,
+ .data_type = 10,
+ .addr_type = 4,
+ .reg_data = 0,
+ .delay = 0,
+ },
+ };
+
+ //...
+ struct reg_settings_t actuator_init_settings[1] = {0};
+
+ struct region_params_t region_params[] = {
+ {
+ .step_bound = {512, 0,},
+ .code_per_step = 118,
+ .qvalue = 128,
+ },
+ };
+
+ actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO;
+ actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){
+ .actuator_params = {
+ .act_type = ACTUATOR_VCM,
+ .reg_tbl_size = 4,
+ .data_size = 10,
+ .init_setting_size = 0,
+ .i2c_freq_mode = I2C_CUSTOM_MODE,
+ .i2c_addr = 28,
+ .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR,
+ .i2c_data_type = MSM_ACTUATOR_BYTE_DATA,
+ .reg_tbl_params = &actuator_reg_params[0],
+ .init_settings = &actuator_init_settings[0],
+ .park_lens = {
+ .damping_step = 1023,
+ .damping_delay = 15000,
+ .hw_params = 58404,
+ .max_step = 20,
+ }
+ },
+ .af_tuning_params = {
+ .initial_code = s->infinity_dac,
+ .pwd_step = 0,
+ .region_size = 1,
+ .total_steps = 512,
+ .region_params = ®ion_params[0],
+ },
+ };
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data);
+ LOG("actuator set info: %d", err);
+
+ // power up ois
+ ois_cfg_data.cfgtype = CFG_OIS_POWERUP;
+ err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data);
+ LOG("ois powerup: %d", err);
+
+ ois_cfg_data.cfgtype = CFG_OIS_INIT;
+ err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data);
+ LOG("ois init: %d", err);
+
+ ois_cfg_data.cfgtype = CFG_OIS_CONTROL;
+ ois_cfg_data.cfg.set_info.ois_params = (struct msm_ois_params_t){
+ // .data_size = 26312,
+ .setting_size = 120,
+ .i2c_addr = 28,
+ .i2c_freq_mode = I2C_CUSTOM_MODE,
+ // .i2c_addr_type = wtf
+ // .i2c_data_type = wtf
+ .settings = &ois_init_settings[0],
+ };
+ err = ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data);
+ LOG("ois init settings: %d", err);
+ } else {
+ // leeco actuator
+ // from sniff
+ s->infinity_dac = 364;
+
+ struct msm_actuator_reg_params_t actuator_reg_params[] = {
+ {
+ .reg_write_type = MSM_ACTUATOR_WRITE_DAC,
+ .hw_mask = 0,
+ .reg_addr = 3,
+ .hw_shift = 0,
+ .data_type = 9,
+ .addr_type = 4,
+ .reg_data = 0,
+ .delay = 0,
+ },
+ };
+
+ struct reg_settings_t actuator_init_settings[] = {
+ { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=1, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 },
+ { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=0, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 },
+ { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=2, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 },
+ { .reg_addr=6, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=64, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 },
+ { .reg_addr=7, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=113, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 },
+ };
+
+ struct region_params_t region_params[] = {
+ {
+ .step_bound = {238, 0,},
+ .code_per_step = 235,
+ .qvalue = 128,
+ },
+ };
+
+ actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO;
+ actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){
+ .actuator_params = {
+ .act_type = ACTUATOR_BIVCM,
+ .reg_tbl_size = 1,
+ .data_size = 10,
+ .init_setting_size = 5,
+ .i2c_freq_mode = I2C_STANDARD_MODE,
+ .i2c_addr = 24,
+ .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR,
+ .i2c_data_type = MSM_ACTUATOR_WORD_DATA,
+ .reg_tbl_params = &actuator_reg_params[0],
+ .init_settings = &actuator_init_settings[0],
+ .park_lens = {
+ .damping_step = 1023,
+ .damping_delay = 14000,
+ .hw_params = 11,
+ .max_step = 20,
+ }
+ },
+ .af_tuning_params = {
+ .initial_code = s->infinity_dac,
+ .pwd_step = 0,
+ .region_size = 1,
+ .total_steps = 238,
+ .region_params = ®ion_params[0],
+ },
+ };
+
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data);
+ LOG("actuator set info: %d", err);
+ }
+ }
+
+ if (s->camera_id == CAMERA_ID_IMX298) {
+ err = sensor_write_regs(s, mode_setting_array_imx298, ARRAYSIZE(mode_setting_array_imx298), MSM_CAMERA_I2C_BYTE_DATA);
+ LOG("sensor setup: %d", err);
+ }
+
+ // CSIPHY: configure csiphy
+ if (s->camera_id == CAMERA_ID_IMX298) {
+ csiphy_params.lane_cnt = 4;
+ csiphy_params.settle_cnt = 14;
+ csiphy_params.lane_mask = 0x1f;
+ csiphy_params.csid_core = 0;
+ } else if (s->camera_id == CAMERA_ID_S5K3P8SP) {
+ csiphy_params.lane_cnt = 4;
+ csiphy_params.settle_cnt = 24;
+ csiphy_params.lane_mask = 0x1f;
+ csiphy_params.csid_core = 0;
+ } else if (s->camera_id == CAMERA_ID_IMX179) {
+ csiphy_params.lane_cnt = 4;
+ csiphy_params.settle_cnt = 11;
+ csiphy_params.lane_mask = 0x1f;
+ csiphy_params.csid_core = 2;
+ } else if (s->camera_id == CAMERA_ID_OV8865) {
+ // guess!
+ csiphy_params.lane_cnt = 4;
+ csiphy_params.settle_cnt = 24;
+ csiphy_params.lane_mask = 0x1f;
+ csiphy_params.csid_core = 2;
+ }
+ csiphy_cfg_data.cfgtype = CSIPHY_CFG;
+ csiphy_cfg_data.cfg.csiphy_params = &csiphy_params;
+ err = ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data);
+ LOG("csiphy configure: %d", err);
+
+ // CSID: configure csid
+ csid_params.lane_cnt = 4;
+ csid_params.lane_assign = 0x4320;
+ if (rear) {
+ csid_params.phy_sel = 0;
+ } else {
+ csid_params.phy_sel = 2;
+ }
+ csid_params.lut_params.num_cid = rear ? 3 : 1;
+
+#define CSI_STATS 0x35
+#define CSI_PD 0x36
+
+ csid_params.lut_params.vc_cfg_a[0].cid = 0;
+ csid_params.lut_params.vc_cfg_a[0].dt = CSI_RAW10;
+ csid_params.lut_params.vc_cfg_a[0].decode_format = CSI_DECODE_10BIT;
+ csid_params.lut_params.vc_cfg_a[1].cid = 1;
+ csid_params.lut_params.vc_cfg_a[1].dt = CSI_PD;
+ csid_params.lut_params.vc_cfg_a[1].decode_format = CSI_DECODE_10BIT;
+ csid_params.lut_params.vc_cfg_a[2].cid = 2;
+ csid_params.lut_params.vc_cfg_a[2].dt = CSI_STATS;
+ csid_params.lut_params.vc_cfg_a[2].decode_format = CSI_DECODE_10BIT;
+
+ csid_params.lut_params.vc_cfg[0] = &csid_params.lut_params.vc_cfg_a[0];
+ csid_params.lut_params.vc_cfg[1] = &csid_params.lut_params.vc_cfg_a[1];
+ csid_params.lut_params.vc_cfg[2] = &csid_params.lut_params.vc_cfg_a[2];
+
+ csid_cfg_data.cfgtype = CSID_CFG;
+ csid_cfg_data.cfg.csid_params = &csid_params;
+ err = ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data);
+ LOG("csid configure: %d", err);
+
+ // ISP: SMMU_ATTACH
+ struct msm_vfe_smmu_attach_cmd smmu_attach_cmd = {
+ .security_mode = 0,
+ .iommu_attach_mode = IOMMU_ATTACH
+ };
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_SMMU_ATTACH, &smmu_attach_cmd);
+ LOG("isp smmu attach: %d", err);
+
+ // ******************* STREAM RAW *****************************
+
+ // configure QMET input
+ for (int i = 0; i < (rear ? 3 : 1); i++) {
+ StreamState *ss = &s->ss[i];
+
+ memset(&input_cfg, 0, sizeof(struct msm_vfe_input_cfg));
+ input_cfg.input_src = VFE_RAW_0+i;
+ input_cfg.input_pix_clk = s->pixel_clock;
+ input_cfg.d.rdi_cfg.cid = i;
+ input_cfg.d.rdi_cfg.frame_based = 1;
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_INPUT_CFG, &input_cfg);
+ LOG("configure input(%d): %d", i, err);
+
+ // ISP: REQUEST_STREAM
+ ss->stream_req.axi_stream_handle = 0;
+ if (rear) {
+ ss->stream_req.session_id = 2;
+ ss->stream_req.stream_id = /*ISP_META_CHANNEL_BIT | */ISP_NATIVE_BUF_BIT | (1+i);
+ } else {
+ ss->stream_req.session_id = 3;
+ ss->stream_req.stream_id = ISP_NATIVE_BUF_BIT | 1;
+ }
+
+ if (i == 0) {
+ ss->stream_req.output_format = v4l2_fourcc('R', 'G', '1', '0');
+ } else {
+ ss->stream_req.output_format = v4l2_fourcc('Q', 'M', 'E', 'T');
+ }
+ ss->stream_req.stream_src = RDI_INTF_0+i;
+
+#ifdef HIGH_FPS
+ if (rear) {
+ ss->stream_req.frame_skip_pattern = EVERY_3FRAME;
+ }
+#endif
+
+ ss->stream_req.frame_base = 1;
+ ss->stream_req.buf_divert = 1; //i == 0;
+
+ // setup stream plane. doesn't even matter?
+ /*s->stream_req.plane_cfg[0].output_plane_format = Y_PLANE;
+ s->stream_req.plane_cfg[0].output_width = s->ci.frame_width;
+ s->stream_req.plane_cfg[0].output_height = s->ci.frame_height;
+ s->stream_req.plane_cfg[0].output_stride = s->ci.frame_width;
+ s->stream_req.plane_cfg[0].output_scan_lines = s->ci.frame_height;
+ s->stream_req.plane_cfg[0].rdi_cid = 0;*/
+
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_STREAM, &ss->stream_req);
+ LOG("isp request stream: %d -> 0x%x", err, ss->stream_req.axi_stream_handle);
+
+ // ISP: REQUEST_BUF
+ ss->buf_request.session_id = ss->stream_req.session_id;
+ ss->buf_request.stream_id = ss->stream_req.stream_id;
+ ss->buf_request.num_buf = FRAME_BUF_COUNT;
+ ss->buf_request.buf_type = ISP_PRIVATE_BUF;
+ ss->buf_request.handle = 0;
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_BUF, &ss->buf_request);
+ LOG("isp request buf: %d", err);
+ LOG("got buf handle: 0x%x", ss->buf_request.handle);
+
+ // ENQUEUE all buffers
+ for (int j = 0; j < ss->buf_request.num_buf; j++) {
+ ss->qbuf_info[j].handle = ss->buf_request.handle;
+ ss->qbuf_info[j].buf_idx = j;
+ ss->qbuf_info[j].buffer.num_planes = 1;
+ ss->qbuf_info[j].buffer.planes[0].addr = ss->bufs[j].fd;
+ ss->qbuf_info[j].buffer.planes[0].length = ss->bufs[j].len;
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss->qbuf_info[j]);
+ }
+
+ // ISP: UPDATE_STREAM
+ update_cmd.num_streams = 1;
+ update_cmd.update_info[0].user_stream_id = ss->stream_req.stream_id;
+ update_cmd.update_info[0].stream_handle = ss->stream_req.axi_stream_handle;
+ update_cmd.update_type = UPDATE_STREAM_ADD_BUFQ;
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_UPDATE_STREAM, &update_cmd);
+ LOG("isp update stream: %d", err);
+ }
+
+ LOG("******** START STREAMS ********");
+
+ sub.id = 0;
+ sub.type = 0x1ff;
+ err = ioctl(s->isp_fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
+ LOG("isp subscribe: %d", err);
+
+ // ISP: START_STREAM
+ s->stream_cfg.cmd = START_STREAM;
+ s->stream_cfg.num_streams = rear ? 3 : 1;
+ for (int i = 0; i < s->stream_cfg.num_streams; i++) {
+ s->stream_cfg.stream_handle[i] = s->ss[i].stream_req.axi_stream_handle;
+ }
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg);
+ LOG("isp start stream: %d", err);
+}
+
+
+static struct damping_params_t actuator_ringing_params = {
+ .damping_step = 1023,
+ .damping_delay = 15000,
+ .hw_params = 0x0000e422,
+};
+
+static void rear_start(CameraState *s) {
+ int err;
+
+ struct msm_actuator_cfg_data actuator_cfg_data = {0};
+
+ set_exposure(s, 1.0, 1.0);
+
+ err = sensor_write_regs(s, start_reg_array, ARRAYSIZE(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA);
+ LOG("sensor start regs: %d", err);
+
+ // focus on infinity assuming phone is perpendicular
+ int inf_step;
+
+ if (s->device != DEVICE_LP3) {
+ imx298_ois_calibration(s->ois_fd, s->eeprom);
+ inf_step = 332 - s->infinity_dac;
+
+ // initial guess
+ s->lens_true_pos = 300;
+ } else {
+ // default is OP3, this is for LeEco
+ actuator_ringing_params.damping_step = 1023;
+ actuator_ringing_params.damping_delay = 20000;
+ actuator_ringing_params.hw_params = 13;
+
+ inf_step = 512 - s->infinity_dac;
+
+ // initial guess
+ s->lens_true_pos = 400;
+ }
+
+ // reset lens position
+ memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data));
+ actuator_cfg_data.cfgtype = CFG_SET_POSITION;
+ actuator_cfg_data.cfg.setpos = (struct msm_actuator_set_position_t){
+ .number_of_steps = 1,
+ .hw_params = (s->device != DEVICE_LP3) ? 0x0000e424 : 7,
+ .pos = {s->infinity_dac, 0},
+ .delay = {0,}
+ };
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data);
+ LOG("actuator set pos: %d", err);
+
+ // TODO: confirm this isn't needed
+ /*memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data));
+ actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS;
+ actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){
+ .dir = 0,
+ .sign_dir = 1,
+ .dest_step_pos = inf_step,
+ .num_steps = inf_step,
+ .curr_lens_pos = 0,
+ .ringing_params = &actuator_ringing_params,
+ };
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); // should be ~332 at startup ?
+ LOG("init actuator move focus: %d", err);*/
+ //actuator_cfg_data.cfg.move.curr_lens_pos;
+
+ s->cur_lens_pos = 0;
+ s->cur_step_pos = inf_step;
+
+ actuator_move(s, s->cur_lens_pos);
+
+ LOG("init lens pos: %d", s->cur_lens_pos);
+}
+
+void actuator_move(CameraState *s, uint16_t target) {
+ int err;
+
+ int step = target - s->cur_lens_pos;
+ // LP3 moves only on even positions. TODO: use proper sensor params
+ if (s->device == DEVICE_LP3) {
+ step /= 2;
+ }
+
+ int dest_step_pos = s->cur_step_pos + step;
+ dest_step_pos = clamp(dest_step_pos, 0, 255);
+
+ struct msm_actuator_cfg_data actuator_cfg_data = {0};
+ actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS;
+ actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){
+ .dir = (step > 0) ? 0 : 1,
+ .sign_dir = (step > 0) ? 1 : -1,
+ .dest_step_pos = dest_step_pos,
+ .num_steps = abs(step),
+ .curr_lens_pos = s->cur_lens_pos,
+ .ringing_params = &actuator_ringing_params,
+ };
+ err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data);
+ LOGD("actuator move focus: %d", err);
+
+ s->cur_step_pos = dest_step_pos;
+ s->cur_lens_pos = actuator_cfg_data.cfg.move.curr_lens_pos;
+
+ LOGD("step %d target: %d lens pos: %d", dest_step_pos, target, s->cur_lens_pos);
+}
+
+static void parse_autofocus(CameraState *s, uint8_t *d) {
+ int good_count = 0;
+ int16_t max_focus = -32767;
+ int avg_focus = 0;
+
+ /*printf("FOCUS: ");
+ for (int i = 0; i < 0x10; i++) {
+ printf("%2.2X ", d[i]);
+ }*/
+
+ for (int i = 0; i < NUM_FOCUS; i++) {
+ int doff = i*5+5;
+ s->confidence[i] = d[doff];
+ int16_t focus_t = (d[doff+1] << 3) | (d[doff+2] >> 5);
+ if (focus_t >= 1024) focus_t = -(2048-focus_t);
+ s->focus[i] = focus_t;
+ //printf("%x->%d ", d[doff], focus_t);
+ if (s->confidence[i] > 0x20) {
+ good_count++;
+ max_focus = max(max_focus, s->focus[i]);
+ avg_focus += s->focus[i];
+ }
+ }
+
+ //printf("\n");
+ if (good_count < 4) {
+ s->focus_err = nan("");
+ return;
+ }
+
+ avg_focus /= good_count;
+
+ // outlier rejection
+ if (abs(avg_focus - max_focus) > 200) {
+ s->focus_err = nan("");
+ return;
+ }
+
+ s->focus_err = max_focus*1.0;
+}
+
+static void do_autofocus(CameraState *s) {
+ // params for focus PI controller
+ const float focus_kp = 0.005;
+
+ float err = s->focus_err;
+ float offset = 0;
+ float sag = (s->last_sag_acc_z/9.8) * 128;
+
+ const int dac_up = s->device == DEVICE_LP3? 634:456;
+ const int dac_down = s->device == DEVICE_LP3? 366:224;
+
+ if (!isnan(err)) {
+ // learn lens_true_pos
+ s->lens_true_pos -= err*focus_kp;
+ }
+
+ // stay off the walls
+ s->lens_true_pos = clamp(s->lens_true_pos, dac_down, dac_up);
+
+ int target = clamp(s->lens_true_pos - sag, dac_down, dac_up);
+
+ char debug[4096];
+ char *pdebug = debug;
+ pdebug += sprintf(pdebug, "focus ");
+ for (int i = 0; i < NUM_FOCUS; i++) pdebug += sprintf(pdebug, "%2x(%4d) ", s->confidence[i], s->focus[i]);
+ pdebug += sprintf(pdebug, " err: %7.2f offset: %6.2f sag: %6.2f lens_true_pos: %6.2f cur_lens_pos: %4d->%4d", err * focus_kp, offset, sag, s->lens_true_pos, s->cur_lens_pos, target);
+ LOGD(debug);
+
+ actuator_move(s, target);
+}
+
+
+static void front_start(CameraState *s) {
+ int err;
+
+ set_exposure(s, 1.0, 1.0);
+
+ err = sensor_write_regs(s, start_reg_array, ARRAYSIZE(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA);
+ LOG("sensor start regs: %d", err);
+}
+
+
+
+void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front) {
+ int err;
+
+ struct ispif_cfg_data ispif_cfg_data = {0};
+
+ struct msm_ispif_param_data ispif_params = {0};
+ ispif_params.num = 4;
+ // rear camera
+ ispif_params.entries[0].vfe_intf = 0;
+ ispif_params.entries[0].intftype = RDI0;
+ ispif_params.entries[0].num_cids = 1;
+ ispif_params.entries[0].cids[0] = 0;
+ ispif_params.entries[0].csid = 0;
+ // front camera
+ ispif_params.entries[1].vfe_intf = 1;
+ ispif_params.entries[1].intftype = RDI0;
+ ispif_params.entries[1].num_cids = 1;
+ ispif_params.entries[1].cids[0] = 0;
+ ispif_params.entries[1].csid = 2;
+ // rear camera (focus)
+ ispif_params.entries[2].vfe_intf = 0;
+ ispif_params.entries[2].intftype = RDI1;
+ ispif_params.entries[2].num_cids = 1;
+ ispif_params.entries[2].cids[0] = 1;
+ ispif_params.entries[2].csid = 0;
+ // rear camera (stats, for AE)
+ ispif_params.entries[3].vfe_intf = 0;
+ ispif_params.entries[3].intftype = RDI2;
+ ispif_params.entries[3].num_cids = 1;
+ ispif_params.entries[3].cids[0] = 2;
+ ispif_params.entries[3].csid = 0;
+
+ assert(camera_bufs_rear);
+ assert(camera_bufs_front);
+
+ int msmcfg_fd = open("/dev/media0", O_RDWR | O_NONBLOCK);
+ assert(msmcfg_fd >= 0);
+
+ sensors_init(s);
+
+ int v4l_fd = open("/dev/video0", O_RDWR | O_NONBLOCK);
+ assert(v4l_fd >= 0);
+
+ if (s->device == DEVICE_LP3) {
+ s->ispif_fd = open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK);
+ } else {
+ s->ispif_fd = open("/dev/v4l-subdev16", O_RDWR | O_NONBLOCK);
+ }
+ assert(s->ispif_fd >= 0);
+
+ // ISPIF: stop
+ // memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data));
+ // ispif_cfg_data.cfg_type = ISPIF_STOP_FRAME_BOUNDARY;
+ // ispif_cfg_data.params = ispif_params;
+ // err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data);
+ // LOG("ispif stop: %d", err);
+
+ LOG("*** open front ***");
+ s->front.ss[0].bufs = camera_bufs_front;
+ camera_open(&s->front, false);
+
+ LOG("*** open rear ***");
+ s->rear.ss[0].bufs = camera_bufs_rear;
+ s->rear.ss[1].bufs = camera_bufs_focus;
+ s->rear.ss[2].bufs = camera_bufs_stats;
+ camera_open(&s->rear, true);
+
+ if (getenv("CAMERA_TEST")) {
+ cameras_close(s);
+ exit(0);
+ }
+
+ // ISPIF: set vfe info
+ memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data));
+ ispif_cfg_data.cfg_type = ISPIF_SET_VFE_INFO;
+ ispif_cfg_data.vfe_info.num_vfe = 2;
+ err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data);
+ LOG("ispif set vfe info: %d", err);
+
+ // ISPIF: setup
+ memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data));
+ ispif_cfg_data.cfg_type = ISPIF_INIT;
+ ispif_cfg_data.csid_version = 0x30050000; //CSID_VERSION_V35
+ err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data);
+ LOG("ispif setup: %d", err);
+
+ memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data));
+ ispif_cfg_data.cfg_type = ISPIF_CFG;
+ ispif_cfg_data.params = ispif_params;
+
+ err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data);
+ LOG("ispif cfg: %d", err);
+
+ ispif_cfg_data.cfg_type = ISPIF_START_FRAME_BOUNDARY;
+ err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data);
+ LOG("ispif start_frame_boundary: %d", err);
+
+ front_start(&s->front);
+ rear_start(&s->rear);
+}
+
+
+static void camera_close(CameraState *s) {
+ int err;
+
+ tbuffer_stop(&s->camera_tb);
+
+ // ISP: STOP_STREAM
+ s->stream_cfg.cmd = STOP_STREAM;
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg);
+ LOG("isp stop stream: %d", err);
+
+ for (int i = 0; i < 3; i++) {
+ StreamState *ss = &s->ss[i];
+ if (ss->stream_req.axi_stream_handle != 0) {
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_BUF, &ss->buf_request);
+ LOG("isp release buf: %d", err);
+
+ struct msm_vfe_axi_stream_release_cmd stream_release = {
+ .stream_handle = ss->stream_req.axi_stream_handle,
+ };
+ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_STREAM, &stream_release);
+ LOG("isp release stream: %d", err);
+ }
+ }
+}
+
+
+const char* get_isp_event_name(unsigned int type) {
+ switch (type) {
+ case ISP_EVENT_REG_UPDATE: return "ISP_EVENT_REG_UPDATE";
+ case ISP_EVENT_EPOCH_0: return "ISP_EVENT_EPOCH_0";
+ case ISP_EVENT_EPOCH_1: return "ISP_EVENT_EPOCH_1";
+ case ISP_EVENT_START_ACK: return "ISP_EVENT_START_ACK";
+ case ISP_EVENT_STOP_ACK: return "ISP_EVENT_STOP_ACK";
+ case ISP_EVENT_IRQ_VIOLATION: return "ISP_EVENT_IRQ_VIOLATION";
+ case ISP_EVENT_STATS_OVERFLOW: return "ISP_EVENT_STATS_OVERFLOW";
+ case ISP_EVENT_ERROR: return "ISP_EVENT_ERROR";
+ case ISP_EVENT_SOF: return "ISP_EVENT_SOF";
+ case ISP_EVENT_EOF: return "ISP_EVENT_EOF";
+ case ISP_EVENT_BUF_DONE: return "ISP_EVENT_BUF_DONE";
+ case ISP_EVENT_BUF_DIVERT: return "ISP_EVENT_BUF_DIVERT";
+ case ISP_EVENT_STATS_NOTIFY: return "ISP_EVENT_STATS_NOTIFY";
+ case ISP_EVENT_COMP_STATS_NOTIFY: return "ISP_EVENT_COMP_STATS_NOTIFY";
+ case ISP_EVENT_FE_READ_DONE: return "ISP_EVENT_FE_READ_DONE";
+ case ISP_EVENT_IOMMU_P_FAULT: return "ISP_EVENT_IOMMU_P_FAULT";
+ case ISP_EVENT_HW_FATAL_ERROR: return "ISP_EVENT_HW_FATAL_ERROR";
+ case ISP_EVENT_PING_PONG_MISMATCH: return "ISP_EVENT_PING_PONG_MISMATCH";
+ case ISP_EVENT_REG_UPDATE_MISSING: return "ISP_EVENT_REG_UPDATE_MISSING";
+ case ISP_EVENT_BUF_FATAL_ERROR: return "ISP_EVENT_BUF_FATAL_ERROR";
+ case ISP_EVENT_STREAM_UPDATE_DONE: return "ISP_EVENT_STREAM_UPDATE_DONE";
+ default: return "unknown";
+ }
+}
+
+static FrameMetadata get_frame_metadata(CameraState *s, uint32_t frame_id) {
+ pthread_mutex_lock(&s->frame_info_lock);
+ for (int i=0; iframe_metadata[i].frame_id == frame_id) {
+ pthread_mutex_unlock(&s->frame_info_lock);
+ return s->frame_metadata[i];
+ }
+ }
+ pthread_mutex_unlock(&s->frame_info_lock);
+
+ // should never happen
+ return (FrameMetadata){
+ .frame_id = -1,
+ };
+}
+
+static bool acceleration_from_sensor_sock(void* sock, float* vs) {
+ int err;
+
+ zmq_msg_t msg;
+ err = zmq_msg_init(&msg);
+ assert(err == 0);
+
+ err = zmq_msg_recv(&msg, sock, 0);
+ assert(err >= 0);
+
+ struct capn ctx;
+ capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0);
+
+ cereal_Event_ptr eventp;
+ eventp.p = capn_getp(capn_root(&ctx), 0, 1);
+ struct cereal_Event eventd;
+ cereal_read_Event(&eventd, eventp);
+
+ bool ret = false;
+
+ if (eventd.which == cereal_Event_sensorEvents) {
+ cereal_SensorEventData_list lst = eventd.sensorEvents;
+ int len = capn_len(lst);
+ for (int i=0; i= 0);
+
+ struct capn ctx;
+ capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0);
+
+ cereal_Event_ptr eventp;
+ eventp.p = capn_getp(capn_root(&ctx), 0, 1);
+ struct cereal_Event eventd;
+ cereal_read_Event(&eventd, eventp);
+
+ bool ret = false;
+
+ if (eventd.which == cereal_Event_liveLocationTiming) {
+ struct cereal_LiveLocationData lld;
+ cereal_read_LiveLocationData(&lld, eventd.liveLocationTiming);
+
+ *mono_time = lld.fixMonoTime;
+ *vs = lld.timeOfWeek;
+ ret = true;
+ }
+
+ capn_free(&ctx);
+ zmq_msg_close(&msg);
+
+ return ret;
+}
+
+static void ops_term() {
+ zsock_t *ops_sock = zsock_new_push(">inproc://cameraops");
+ assert(ops_sock);
+
+ CameraMsg msg = {.type = -1};
+ zmq_send(zsock_resolve(ops_sock), &msg, sizeof(msg), ZMQ_DONTWAIT);
+
+ zsock_destroy(&ops_sock);
+}
+
+static void* ops_thread(void* arg) {
+ int err;
+ DualCameraState *s = (DualCameraState*)arg;
+
+ set_thread_name("camera_settings");
+
+ zsock_t *cameraops = zsock_new_pull("@inproc://cameraops");
+ assert(cameraops);
+
+ zsock_t *sensor_sock = zsock_new_sub(">tcp://127.0.0.1:8003", "");
+ assert(sensor_sock);
+
+ zsock_t *livelocationtiming_sock = zsock_new_sub(">tcp://127.0.0.1:8049", "");
+ assert(livelocationtiming_sock);
+
+ zsock_t *terminate = zsock_new_sub(">inproc://terminate", "");
+ assert(terminate);
+
+ zpoller_t *poller = zpoller_new(cameraops, sensor_sock, livelocationtiming_sock, terminate, NULL);
+ assert(poller);
+
+ while (!do_exit) {
+
+ zsock_t *which = (zsock_t*)zpoller_wait(poller, -1);
+ if (which == terminate || which == NULL) {
+ break;
+ }
+ void* sockraw = zsock_resolve(which);
+
+ if (which == cameraops) {
+ zmq_msg_t msg;
+ err = zmq_msg_init(&msg);
+ assert(err == 0);
+
+ err = zmq_msg_recv(&msg, sockraw, 0);
+ assert(err >= 0);
+
+ CameraMsg cmsg;
+ if (zmq_msg_size(&msg) == sizeof(cmsg)) {
+ memcpy(&cmsg, zmq_msg_data(&msg), zmq_msg_size(&msg));
+
+ LOGD("cameraops %d", cmsg.type);
+
+ if (cmsg.type == CAMERA_MSG_AUTOEXPOSE) {
+ if (cmsg.camera_num == 0) {
+ do_autoexposure(&s->rear, cmsg.grey_frac);
+ do_autofocus(&s->rear);
+ } else {
+ do_autoexposure(&s->front, cmsg.grey_frac);
+ }
+ } else if (cmsg.type == -1) {
+ break;
+ }
+ }
+
+ zmq_msg_close(&msg);
+
+ } else if (which == sensor_sock) {
+ float vs[3] = {0.0};
+ bool got_accel = acceleration_from_sensor_sock(sockraw, vs);
+
+ uint64_t ts = nanos_since_boot();
+ if (got_accel && ts - s->rear.last_sag_ts > 10000000) { // 10 ms
+ s->rear.last_sag_ts = ts;
+ s->rear.last_sag_acc_z = -vs[2];
+ }
+ } else if (which == livelocationtiming_sock) {
+ uint64_t mono_time;
+ double gps_time;
+ if (gps_time_from_timing_sock(sockraw, &mono_time, &gps_time)) {
+ s->rear.global_time_offset = (uint64_t)(gps_time*1e9) - mono_time;
+ //LOGW("%f %lld = %lld", gps_time, mono_time, s->rear.global_time_offset);
+ s->rear.phase_request = 10000000;
+ s->rear.using_pll = true;
+ }
+ }
+ }
+
+ zpoller_destroy(&poller);
+ zsock_destroy(&cameraops);
+ zsock_destroy(&sensor_sock);
+ zsock_destroy(&terminate);
+
+ return NULL;
+}
+
+void cameras_run(DualCameraState *s) {
+ int err;
+
+ pthread_t ops_thread_handle;
+ err = pthread_create(&ops_thread_handle, NULL,
+ ops_thread, s);
+ assert(err == 0);
+
+ CameraState* cameras[2] = {&s->rear, &s->front};
+
+ while (!do_exit) {
+ struct pollfd fds[2] = {{0}};
+
+ fds[0].fd = cameras[0]->isp_fd;
+ fds[0].events = POLLPRI;
+
+ fds[1].fd = cameras[1]->isp_fd;
+ fds[1].events = POLLPRI;
+
+ int ret = poll(fds, ARRAYSIZE(fds), 1000);
+ if (ret <= 0) {
+ LOGE("poll failed (%d)", ret);
+ break;
+ }
+
+ // process cameras
+ for (int i=0; i<2; i++) {
+ if (!fds[i].revents) continue;
+
+ CameraState *c = cameras[i];
+
+ struct v4l2_event ev;
+ ret = ioctl(c->isp_fd, VIDIOC_DQEVENT, &ev);
+ struct msm_isp_event_data *isp_event_data = (struct msm_isp_event_data *)ev.u.data;
+ unsigned int event_type = ev.type;
+
+ uint64_t timestamp = (isp_event_data->mono_timestamp.tv_sec*1000000000ULL
+ + isp_event_data->mono_timestamp.tv_usec*1000);
+
+ int buf_idx = isp_event_data->u.buf_done.buf_idx;
+ int stream_id = isp_event_data->u.buf_done.stream_id;
+ int buffer = (stream_id&0xFFFF) - 1;
+
+ uint64_t t = nanos_since_boot();
+
+ /*if (i == 1) {
+ printf("%10.2f: VIDIOC_DQEVENT: %d type:%X (%s)\n", t*1.0/1e6, ret, event_type, get_isp_event_name(event_type));
+ }*/
+
+ // printf("%d: %s\n", i, get_isp_event_name(event_type));
+
+ switch (event_type) {
+ case ISP_EVENT_BUF_DIVERT:
+
+ /*if (c->is_samsung) {
+ printf("write %d\n", c->frame_size);
+ FILE *f = fopen("/tmp/test", "wb");
+ fwrite((void*)c->camera_bufs[i].addr, 1, c->frame_size, f);
+ fclose(f);
+ }*/
+ //printf("divert: %d %d %d\n", i, buffer, buf_idx);
+
+ if (buffer == 0) {
+ c->camera_bufs_metadata[buf_idx] = get_frame_metadata(c, isp_event_data->frame_id);
+ tbuffer_dispatch(&c->camera_tb, buf_idx);
+ } else {
+ uint8_t *d = c->ss[buffer].bufs[buf_idx].addr;
+ if (buffer == 1) {
+ parse_autofocus(c, d);
+ }
+ c->ss[buffer].qbuf_info[buf_idx].dirty_buf = 1;
+ ioctl(c->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &c->ss[buffer].qbuf_info[buf_idx]);
+ }
+ break;
+ case ISP_EVENT_EOF:
+ // printf("ISP_EVENT_EOF delta %f\n", (t-last_t)/1e6);
+ c->last_t = t;
+
+ if (c->using_pll) {
+ int mod = ((int)1000000000 / c->fps);
+ c->phase_actual = (((timestamp + c->global_time_offset) % mod) + mod) % mod;
+ LOGD("phase is %12d request is %12d with offset %lld", c->phase_actual, c->phase_request, c->global_time_offset);
+ }
+
+ pthread_mutex_lock(&c->frame_info_lock);
+ c->frame_metadata[c->frame_metadata_idx] = (FrameMetadata){
+ .frame_id = isp_event_data->frame_id,
+ .timestamp_eof = timestamp,
+ .frame_length = c->cur_frame_length,
+ .integ_lines = c->cur_integ_lines,
+ .global_gain = c->cur_gain,
+ .lens_pos = c->cur_lens_pos,
+ .lens_sag = c->last_sag_acc_z,
+ .lens_err = c->focus_err,
+ .lens_true_pos = c->lens_true_pos,
+ };
+ c->frame_metadata_idx = (c->frame_metadata_idx+1)%METADATA_BUF_COUNT;
+ pthread_mutex_unlock(&c->frame_info_lock);
+
+ break;
+ case ISP_EVENT_ERROR:
+ LOGE("ISP_EVENT_ERROR! err type: 0x%08x", isp_event_data->u.error_info.err_type);
+ break;
+ }
+ }
+ }
+
+ LOG(" ************** STOPPING **************");
+
+ ops_term();
+ err = pthread_join(ops_thread_handle, NULL);
+ assert(err == 0);
+
+ cameras_close(s);
+}
+
+void cameras_close(DualCameraState *s) {
+ camera_close(&s->rear);
+ camera_close(&s->front);
+}
+
diff --git a/selfdrive/visiond/camera_qcom.h b/selfdrive/visiond/camera_qcom.h
new file mode 100644
index 00000000000000..0cc8f844a57477
--- /dev/null
+++ b/selfdrive/visiond/camera_qcom.h
@@ -0,0 +1,138 @@
+#ifndef CAMERA_H
+#define CAMERA_H
+
+#include
+#include
+#include
+
+#include "msmb_isp.h"
+#include "msmb_ispif.h"
+#include "msmb_camera.h"
+#include "msm_cam_sensor.h"
+
+#include "common/mat.h"
+#include "common/visionbuf.h"
+#include "common/buffering.h"
+
+#include "camera_common.h"
+
+#define FRAME_BUF_COUNT 4
+#define METADATA_BUF_COUNT 4
+
+#define DEVICE_OP3 0
+#define DEVICE_OP3T 1
+#define DEVICE_LP3 2
+
+#define NUM_FOCUS 8
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct CameraState CameraState;
+
+typedef int (*camera_apply_exposure_func)(CameraState *s, int gain, int integ_lines, int frame_length);
+
+typedef struct StreamState {
+ struct msm_isp_buf_request buf_request;
+ struct msm_vfe_axi_stream_request_cmd stream_req;
+ struct msm_isp_qbuf_info qbuf_info[FRAME_BUF_COUNT];
+ VisionBuf *bufs;
+} StreamState;
+
+typedef struct CameraState {
+ int camera_num;
+ int camera_id;
+ CameraInfo ci;
+ int frame_size;
+
+ int device;
+
+ void* ops_sock;
+
+ uint32_t pixel_clock;
+ uint32_t line_length_pclk;
+ unsigned int max_gain;
+
+ // PLL to sync cameras in time
+ // assumes at least 1 FPS
+ bool using_pll;
+ int phase_actual;
+ int phase_request;
+ int64_t global_time_offset;
+
+ int csid_fd;
+ int csiphy_fd;
+ int sensor_fd;
+ int isp_fd;
+ int eeprom_fd;
+ // rear only
+ int ois_fd, actuator_fd;
+ uint16_t infinity_dac;
+
+ struct msm_vfe_axi_stream_cfg_cmd stream_cfg;
+
+ size_t eeprom_size;
+ uint8_t *eeprom;
+
+ // uint32_t camera_bufs_ids[FRAME_BUF_COUNT];
+ FrameMetadata camera_bufs_metadata[FRAME_BUF_COUNT];
+ TBuffer camera_tb;
+
+ pthread_mutex_t frame_info_lock;
+ FrameMetadata frame_metadata[METADATA_BUF_COUNT];
+ int frame_metadata_idx;
+ float cur_exposure_frac;
+ float cur_gain_frac;
+ int cur_gain;
+ int cur_frame_length;
+ int cur_integ_lines;
+
+ float digital_gain;
+
+ StreamState ss[3];
+
+ uint64_t last_t;
+
+ camera_apply_exposure_func apply_exposure;
+
+ int16_t focus[NUM_FOCUS];
+ uint8_t confidence[NUM_FOCUS];
+
+ float focus_err;
+
+ uint16_t cur_step_pos;
+ uint16_t cur_lens_pos;
+ uint64_t last_sag_ts;
+ float last_sag_acc_z;
+ float lens_true_pos;
+
+ int fps;
+
+ mat3 transform;
+} CameraState;
+
+
+typedef struct DualCameraState {
+ int device;
+
+ int ispif_fd;
+
+ CameraState rear;
+ CameraState front;
+} DualCameraState;
+
+void cameras_init(DualCameraState *s);
+void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front);
+void cameras_run(DualCameraState *s);
+void cameras_close(DualCameraState *s);
+
+void camera_autoexposure(CameraState *s, float grey_frac);
+void actuator_move(CameraState *s, uint16_t target);
+int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
diff --git a/selfdrive/visiond/clutil.c b/selfdrive/visiond/clutil.c
new file mode 100644
index 00000000000000..0040e4dd6af6ad
--- /dev/null
+++ b/selfdrive/visiond/clutil.c
@@ -0,0 +1,418 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#include "common/util.h"
+
+#include "clutil.h"
+
+typedef struct CLUProgramIndex {
+ uint64_t index_hash;
+ const uint8_t* bin_data;
+ const uint8_t* bin_end;
+} CLUProgramIndex;
+
+#ifdef CLU_NO_SRC
+#include "clcache_bins.h"
+#else
+static const CLUProgramIndex clu_index[] = {};
+#endif
+
+void clu_init(void) {
+#ifndef CLU_NO_SRC
+ mkdir("/tmp/clcache", 0777);
+ unlink("/tmp/clcache/index.cli");
+#endif
+}
+
+cl_program cl_create_program_from_file(cl_context ctx, const char* path) {
+ char* src_buf = read_file(path, NULL);
+ assert(src_buf);
+
+ int err = 0;
+ cl_program ret = clCreateProgramWithSource(ctx, 1, (const char**)&src_buf, NULL, &err);
+ assert(err == 0);
+
+ free(src_buf);
+
+ return ret;
+}
+
+static char* get_version_string(cl_platform_id platform) {
+ size_t size = 0;
+ int err;
+ err = clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
+ assert(err == 0);
+ char *str = malloc(size);
+ assert(str);
+ err = clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, str, NULL);
+ assert(err == 0);
+ return str;
+}
+
+void cl_print_info(cl_platform_id platform, cl_device_id device) {
+ char str[4096];
+
+ clGetPlatformInfo(platform, CL_PLATFORM_VENDOR, sizeof(str), str, NULL);
+ printf("vendor: '%s'\n", str);
+
+ char* version = get_version_string(platform);
+ printf("platform version: '%s'\n", version);
+ free(version);
+
+ clGetPlatformInfo(platform, CL_PLATFORM_PROFILE, sizeof(str), str, NULL);
+ printf("profile: '%s'\n", str);
+
+ clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, sizeof(str), str, NULL);
+ printf("extensions: '%s'\n", str);
+
+ clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(str), str, NULL);
+ printf("name: '%s'\n", str);
+
+ clGetDeviceInfo(device, CL_DEVICE_VERSION, sizeof(str), str, NULL);
+ printf("device version: '%s'\n", str);
+
+ size_t sz;
+ clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(sz), &sz, NULL);
+ printf("max work group size: %u\n", sz);
+
+ cl_device_type type;
+ clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
+ printf("type = 0x%04x = ", (unsigned int)type);
+ switch(type) {
+ case CL_DEVICE_TYPE_CPU:
+ printf("CL_DEVICE_TYPE_CPU\n");
+ break;
+ case CL_DEVICE_TYPE_GPU:
+ printf("CL_DEVICE_TYPE_GPU\n");
+ break;
+ case CL_DEVICE_TYPE_ACCELERATOR:
+ printf("CL_DEVICE_TYPE_ACCELERATOR\n");
+ break;
+ default:
+ printf("Other...\n" );
+ break;
+ }
+}
+
+void cl_print_build_errors(cl_program program, cl_device_id device) {
+ cl_build_status status;
+ clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS,
+ sizeof(cl_build_status), &status, NULL);
+
+ size_t log_size;
+ clGetProgramBuildInfo(program, device,
+ CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
+
+ char* log = calloc(log_size+1, 1);
+ assert(log);
+
+ clGetProgramBuildInfo(program, device,
+ CL_PROGRAM_BUILD_LOG, log_size+1, log, NULL);
+
+ printf("build failed; status=%d, log:\n%s\n",
+ status, log);
+
+ free(log);
+}
+
+uint64_t clu_index_hash(const char* s) {
+ size_t sl = strlen(s);
+ assert(sl < 128);
+ uint64_t x = 0;
+ for (int i=127; i>=0; i--) {
+ x *= 65599ULL;
+ x += (uint8_t)s[i> 32);
+}
+
+uint64_t clu_fnv_hash(const uint8_t *data, size_t len) {
+ /* 64 bit Fowler/Noll/Vo FNV-1a hash code */
+ uint64_t hval = 0xcbf29ce484222325ULL;
+ const uint8_t *dp = data;
+ const uint8_t *de = data + len;
+ while (dp < de) {
+ hval ^= (uint64_t) *dp++;
+ hval += (hval << 1) + (hval << 4) + (hval << 5) +
+ (hval << 7) + (hval << 8) + (hval << 40);
+ }
+
+ return hval;
+}
+
+cl_program cl_cached_program_from_hash(cl_context ctx, cl_device_id device_id, uint64_t hash) {
+ int err;
+
+ char cache_path[1024];
+ snprintf(cache_path, sizeof(cache_path), "/tmp/clcache/%016" PRIx64 ".clb", hash);
+
+ size_t bin_size;
+ uint8_t *bin = read_file(cache_path, &bin_size);
+ if (!bin) {
+ return NULL;
+ }
+
+ cl_program prg = clCreateProgramWithBinary(ctx, 1, &device_id, &bin_size, (const uint8_t**)&bin, NULL, &err);
+ assert(err == 0);
+
+ free(bin);
+
+ err = clBuildProgram(prg, 1, &device_id, NULL, NULL, NULL);
+ assert(err == 0);
+
+ return prg;
+}
+
+static uint8_t* get_program_binary(cl_program prg, size_t *out_size) {
+ int err;
+
+ cl_uint num_devices;
+ err = clGetProgramInfo(prg, CL_PROGRAM_NUM_DEVICES, sizeof(num_devices), &num_devices, NULL);
+ assert(err == 0);
+ assert(num_devices == 1);
+
+ size_t binary_size = 0;
+ err = clGetProgramInfo(prg, CL_PROGRAM_BINARY_SIZES, sizeof(binary_size), &binary_size, NULL);
+ assert(err == 0);
+ assert(binary_size > 0);
+
+ uint8_t *binary_buf = malloc(binary_size);
+ assert(binary_buf);
+
+ uint8_t* bufs[1] = { binary_buf, };
+
+ err = clGetProgramInfo(prg, CL_PROGRAM_BINARIES, sizeof(bufs), &bufs, NULL);
+ assert(err == 0);
+
+ *out_size = binary_size;
+ return binary_buf;
+}
+
+cl_program cl_cached_program_from_string(cl_context ctx, cl_device_id device_id,
+ const char* src, const char* args,
+ uint64_t *out_hash) {
+ int err;
+
+ cl_platform_id platform;
+ err = clGetDeviceInfo(device_id, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
+ assert(err == 0);
+
+ const char* platform_version = get_version_string(platform);
+
+ const size_t hash_len = strlen(platform_version)+1+strlen(src)+1+strlen(args)+1;
+ char* hash_buf = malloc(hash_len);
+ assert(hash_buf);
+ memset(hash_buf, 0, hash_len);
+ snprintf(hash_buf, hash_len, "%s%c%s%c%s", platform_version, 1, src, 1, args);
+ free((void*)platform_version);
+
+ uint64_t hash = clu_fnv_hash((uint8_t*)hash_buf, hash_len);
+ free(hash_buf);
+
+ cl_program prg = NULL;
+#ifndef CLU_NO_CACHE
+ prg = cl_cached_program_from_hash(ctx, device_id, hash);
+#endif
+ if (prg == NULL) {
+ prg = clCreateProgramWithSource(ctx, 1, (const char**)&src, NULL, &err);
+ assert(err == 0);
+
+ err = clBuildProgram(prg, 1, &device_id, args, NULL, NULL);
+ if (err != 0) {
+ cl_print_build_errors(prg, device_id);
+ }
+ assert(err == 0);
+
+#ifndef CLU_NO_CACHE
+ // write program binary to cache
+
+ size_t binary_size;
+ uint8_t *binary_buf = get_program_binary(prg, &binary_size);
+
+ char cache_path[1024];
+ snprintf(cache_path, sizeof(cache_path), "/tmp/clcache/%016" PRIx64 ".clb", hash);
+ FILE* of = fopen(cache_path, "wb");
+ assert(of);
+ fwrite(binary_buf, 1, binary_size, of);
+ fclose(of);
+
+ free(binary_buf);
+#endif
+ }
+
+ if (out_hash) *out_hash = hash;
+ return prg;
+}
+
+cl_program cl_cached_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args,
+ uint64_t *out_hash) {
+ char* src_buf = read_file(path, NULL);
+ assert(src_buf);
+ cl_program ret = cl_cached_program_from_string(ctx, device_id, src_buf, args, out_hash);
+ free(src_buf);
+ return ret;
+}
+
+static void add_index(uint64_t index_hash, uint64_t src_hash) {
+ FILE *f = fopen("/tmp/clcache/index.cli", "a");
+ assert(f);
+ fprintf(f, "%016" PRIx64 " %016" PRIx64 "\n", index_hash, src_hash);
+ fclose(f);
+}
+
+
+cl_program cl_program_from_index(cl_context ctx, cl_device_id device_id, uint64_t index_hash) {
+ int err;
+
+ int i;
+ for (i=0; i= ARRAYSIZE(clu_index)) {
+ assert(false);
+ }
+
+ size_t bin_size = clu_index[i].bin_end - clu_index[i].bin_data;
+ const uint8_t *bin_data = clu_index[i].bin_data;
+
+ cl_program prg = clCreateProgramWithBinary(ctx, 1, &device_id, &bin_size, (const uint8_t**)&bin_data, NULL, &err);
+ assert(err == 0);
+
+ err = clBuildProgram(prg, 1, &device_id, NULL, NULL, NULL);
+ assert(err == 0);
+
+ return prg;
+}
+
+cl_program cl_index_program_from_string(cl_context ctx, cl_device_id device_id,
+ const char* src, const char* args,
+ uint64_t index_hash) {
+ uint64_t src_hash = 0;
+ cl_program ret = cl_cached_program_from_string(ctx, device_id, src, args, &src_hash);
+#ifndef CLU_NO_CACHE
+ add_index(index_hash, src_hash);
+#endif
+ return ret;
+}
+
+cl_program cl_index_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args,
+ uint64_t index_hash) {
+ uint64_t src_hash = 0;
+ cl_program ret = cl_cached_program_from_file(ctx, device_id, path, args, &src_hash);
+#ifndef CLU_NO_CACHE
+ add_index(index_hash, src_hash);
+#endif
+ return ret;
+}
+
+/*
+ * Given a cl code and return a string represenation
+ */
+const char* cl_get_error_string(int err) {
+ switch (err) {
+ case 0: return "CL_SUCCESS";
+ case -1: return "CL_DEVICE_NOT_FOUND";
+ case -2: return "CL_DEVICE_NOT_AVAILABLE";
+ case -3: return "CL_COMPILER_NOT_AVAILABLE";
+ case -4: return "CL_MEM_OBJECT_ALLOCATION_FAILURE";
+ case -5: return "CL_OUT_OF_RESOURCES";
+ case -6: return "CL_OUT_OF_HOST_MEMORY";
+ case -7: return "CL_PROFILING_INFO_NOT_AVAILABLE";
+ case -8: return "CL_MEM_COPY_OVERLAP";
+ case -9: return "CL_IMAGE_FORMAT_MISMATCH";
+ case -10: return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
+ case -12: return "CL_MAP_FAILURE";
+ case -13: return "CL_MISALIGNED_SUB_BUFFER_OFFSET";
+ case -14: return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST";
+ case -15: return "CL_COMPILE_PROGRAM_FAILURE";
+ case -16: return "CL_LINKER_NOT_AVAILABLE";
+ case -17: return "CL_LINK_PROGRAM_FAILURE";
+ case -18: return "CL_DEVICE_PARTITION_FAILED";
+ case -19: return "CL_KERNEL_ARG_INFO_NOT_AVAILABLE";
+ case -30: return "CL_INVALID_VALUE";
+ case -31: return "CL_INVALID_DEVICE_TYPE";
+ case -32: return "CL_INVALID_PLATFORM";
+ case -33: return "CL_INVALID_DEVICE";
+ case -34: return "CL_INVALID_CONTEXT";
+ case -35: return "CL_INVALID_QUEUE_PROPERTIES";
+ case -36: return "CL_INVALID_COMMAND_QUEUE";
+ case -37: return "CL_INVALID_HOST_PTR";
+ case -38: return "CL_INVALID_MEM_OBJECT";
+ case -39: return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
+ case -40: return "CL_INVALID_IMAGE_SIZE";
+ case -41: return "CL_INVALID_SAMPLER";
+ case -42: return "CL_INVALID_BINARY";
+ case -43: return "CL_INVALID_BUILD_OPTIONS";
+ case -44: return "CL_INVALID_PROGRAM";
+ case -45: return "CL_INVALID_PROGRAM_EXECUTABLE";
+ case -46: return "CL_INVALID_KERNEL_NAME";
+ case -47: return "CL_INVALID_KERNEL_DEFINITION";
+ case -48: return "CL_INVALID_KERNEL";
+ case -49: return "CL_INVALID_ARG_INDEX";
+ case -50: return "CL_INVALID_ARG_VALUE";
+ case -51: return "CL_INVALID_ARG_SIZE";
+ case -52: return "CL_INVALID_KERNEL_ARGS";
+ case -53: return "CL_INVALID_WORK_DIMENSION";
+ case -54: return "CL_INVALID_WORK_GROUP_SIZE";
+ case -55: return "CL_INVALID_WORK_ITEM_SIZE";
+ case -56: return "CL_INVALID_GLOBAL_OFFSET";
+ case -57: return "CL_INVALID_EVENT_WAIT_LIST";
+ case -58: return "CL_INVALID_EVENT";
+ case -59: return "CL_INVALID_OPERATION";
+ case -60: return "CL_INVALID_GL_OBJECT";
+ case -61: return "CL_INVALID_BUFFER_SIZE";
+ case -62: return "CL_INVALID_MIP_LEVEL";
+ case -63: return "CL_INVALID_GLOBAL_WORK_SIZE";
+ case -64: return "CL_INVALID_PROPERTY";
+ case -65: return "CL_INVALID_IMAGE_DESCRIPTOR";
+ case -66: return "CL_INVALID_COMPILER_OPTIONS";
+ case -67: return "CL_INVALID_LINKER_OPTIONS";
+ case -68: return "CL_INVALID_DEVICE_PARTITION_COUNT";
+ case -69: return "CL_INVALID_PIPE_SIZE";
+ case -70: return "CL_INVALID_DEVICE_QUEUE";
+ case -71: return "CL_INVALID_SPEC_ID";
+ case -72: return "CL_MAX_SIZE_RESTRICTION_EXCEEDED";
+ case -1002: return "CL_INVALID_D3D10_DEVICE_KHR";
+ case -1003: return "CL_INVALID_D3D10_RESOURCE_KHR";
+ case -1004: return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR";
+ case -1005: return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR";
+ case -1006: return "CL_INVALID_D3D11_DEVICE_KHR";
+ case -1007: return "CL_INVALID_D3D11_RESOURCE_KHR";
+ case -1008: return "CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR";
+ case -1009: return "CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR";
+ case -1010: return "CL_INVALID_DX9_MEDIA_ADAPTER_KHR";
+ case -1011: return "CL_INVALID_DX9_MEDIA_SURFACE_KHR";
+ case -1012: return "CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR";
+ case -1013: return "CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR";
+ case -1093: return "CL_INVALID_EGL_OBJECT_KHR";
+ case -1092: return "CL_EGL_RESOURCE_NOT_ACQUIRED_KHR";
+ case -1001: return "CL_PLATFORM_NOT_FOUND_KHR";
+ case -1057: return "CL_DEVICE_PARTITION_FAILED_EXT";
+ case -1058: return "CL_INVALID_PARTITION_COUNT_EXT";
+ case -1059: return "CL_INVALID_PARTITION_NAME_EXT";
+ case -1094: return "CL_INVALID_ACCELERATOR_INTEL";
+ case -1095: return "CL_INVALID_ACCELERATOR_TYPE_INTEL";
+ case -1096: return "CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL";
+ case -1097: return "CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL";
+ case -1000: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR";
+ case -1098: return "CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL";
+ case -1099: return "CL_INVALID_VA_API_MEDIA_SURFACE_INTEL";
+ case -1100: return "CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL";
+ case -1101: return "CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL";
+ default: return "CL_UNKNOWN_ERROR";
+ }
+}
diff --git a/selfdrive/visiond/clutil.h b/selfdrive/visiond/clutil.h
new file mode 100644
index 00000000000000..b87961eacdfbf8
--- /dev/null
+++ b/selfdrive/visiond/clutil.h
@@ -0,0 +1,87 @@
+#ifndef CLUTIL_H
+#define CLUTIL_H
+
+#include
+#include
+#include
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void clu_init(void);
+
+cl_program cl_create_program_from_file(cl_context ctx, const char* path);
+void cl_print_info(cl_platform_id platform, cl_device_id device);
+void cl_print_build_errors(cl_program program, cl_device_id device);
+void cl_print_build_errors(cl_program program, cl_device_id device);
+
+cl_program cl_cached_program_from_hash(cl_context ctx, cl_device_id device_id, uint64_t hash);
+cl_program cl_cached_program_from_string(cl_context ctx, cl_device_id device_id,
+ const char* src, const char* args,
+ uint64_t *out_hash);
+cl_program cl_cached_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args,
+ uint64_t *out_hash);
+
+cl_program cl_program_from_index(cl_context ctx, cl_device_id device_id, uint64_t index_hash);
+
+cl_program cl_index_program_from_string(cl_context ctx, cl_device_id device_id,
+ const char* src, const char* args,
+ uint64_t index_hash);
+cl_program cl_index_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args,
+ uint64_t index_hash);
+
+uint64_t clu_index_hash(const char *s);
+uint64_t clu_fnv_hash(const uint8_t *data, size_t len);
+
+const char* cl_get_error_string(int err);
+
+static inline int cl_check_error(int err) {
+ if (err != 0) {
+ fprintf(stderr, "%s\n", cl_get_error_string(err));
+ exit(1);
+ }
+ return err;
+}
+
+
+// // string hash macro. compiler, I'm so sorry.
+#define CLU_H1(s,i,x) (x*65599ULL+(uint8_t)s[(i)>32)))
+
+#define CLU_STRINGIFY(x) #x
+#define CLU_STRINGIFY2(x) CLU_STRINGIFY(x)
+#define CLU_LINESTR CLU_STRINGIFY2(__LINE__)
+
+#ifdef CLU_NO_SRC
+
+ #define CLU_LOAD_FROM_STRING(ctx, device_id, src, args) \
+ cl_program_from_index(ctx, device_id, CLU_HASH("\1" __FILE__ "\1" CLU_LINESTR) ^ clu_fnv_hash((const uint8_t*)__func__, strlen(__func__)) ^ clu_fnv_hash((const uint8_t*)args, strlen(args)))
+ #define CLU_LOAD_FROM_FILE(ctx, device_id, path, args) \
+ cl_program_from_index(ctx, device_id, CLU_HASH("\2" path) ^ clu_fnv_hash((const uint8_t*)args, strlen(args)))
+
+#else
+
+ #define CLU_LOAD_FROM_STRING(ctx, device_id, src, args) \
+ cl_index_program_from_string(ctx, device_id, src, args, clu_index_hash("\1" __FILE__ "\1" CLU_LINESTR) ^ clu_fnv_hash((const uint8_t*)__func__, strlen(__func__)) ^ clu_fnv_hash((const uint8_t*)args, strlen(args)))
+ #define CLU_LOAD_FROM_FILE(ctx, device_id, path, args) \
+ cl_index_program_from_file(ctx, device_id, path, args, clu_index_hash("\2" path) ^ clu_fnv_hash((const uint8_t*)args, strlen(args)))
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/selfdrive/visiond/commonmodel.c b/selfdrive/visiond/commonmodel.c
new file mode 100644
index 00000000000000..595d2609e74d4e
--- /dev/null
+++ b/selfdrive/visiond/commonmodel.c
@@ -0,0 +1,155 @@
+#include "commonmodel.h"
+
+#include
+#include "cereal/gen/c/log.capnp.h"
+#include "common/mat.h"
+#include "common/timing.h"
+
+void model_input_init(ModelInput* s, int width, int height,
+ cl_device_id device_id, cl_context context) {
+ int err;
+ s->device_id = device_id;
+ s->context = context;
+
+ transform_init(&s->transform, context, device_id);
+ s->transformed_width = width;
+ s->transformed_height = height;
+
+ s->transformed_y_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE,
+ s->transformed_width*s->transformed_height, NULL, &err);
+ assert(err == 0);
+ s->transformed_u_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE,
+ (s->transformed_width/2)*(s->transformed_height/2), NULL, &err);
+ assert(err == 0);
+ s->transformed_v_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE,
+ (s->transformed_width/2)*(s->transformed_height/2), NULL, &err);
+ assert(err == 0);
+
+ s->net_input_size = ((width*height*3)/2)*sizeof(float);
+ s->net_input = clCreateBuffer(s->context, CL_MEM_READ_WRITE,
+ s->net_input_size, (void*)NULL, &err);
+ assert(err == 0);
+
+ loadyuv_init(&s->loadyuv, context, device_id, s->transformed_width, s->transformed_height);
+}
+
+float *model_input_prepare(ModelInput* s, cl_command_queue q,
+ cl_mem yuv_cl, int width, int height,
+ mat3 transform) {
+ int err;
+ int i = 0;
+ transform_queue(&s->transform, q,
+ yuv_cl, width, height,
+ s->transformed_y_cl, s->transformed_u_cl, s->transformed_v_cl,
+ s->transformed_width, s->transformed_height,
+ transform);
+ loadyuv_queue(&s->loadyuv, q,
+ s->transformed_y_cl, s->transformed_u_cl, s->transformed_v_cl,
+ s->net_input);
+ float *net_input_buf = (float *)clEnqueueMapBuffer(q, s->net_input, CL_TRUE,
+ CL_MAP_READ, 0, s->net_input_size,
+ 0, NULL, NULL, &err);
+ clFinish(q);
+ return net_input_buf;
+}
+
+void model_input_free(ModelInput* s) {
+ transform_destroy(&s->transform);
+ loadyuv_destroy(&s->loadyuv);
+}
+
+
+void softmax(const float* input, float* output, size_t len) {
+ float max_val = -FLT_MAX;
+ for(int i = 0; i < len; i++) {
+ const float v = input[i];
+ if( v > max_val ) {
+ max_val = v;
+ }
+ }
+
+ float denominator = 0;
+ for(int i = 0; i < len; i++) {
+ float const v = input[i];
+ float const v_exp = expf(v - max_val);
+ denominator += v_exp;
+ output[i] = v_exp;
+ }
+
+ const float inv_denominator = 1. / denominator;
+ for(int i = 0; i < len; i++) {
+ output[i] *= inv_denominator;
+ }
+
+}
+
+
+static cereal_ModelData_PathData_ptr path_to_cereal(struct capn_segment *cs, const PathData data) {
+ capn_list32 points_ptr = capn_new_list32(cs, MODEL_PATH_DISTANCE);
+ for (int i=0; i
+
+#include "common/mat.h"
+#include "common/modeldata.h"
+#include "transform.h"
+#include "loadyuv.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void softmax(const float* input, float* output, size_t len);
+
+typedef struct ModelInput {
+ cl_device_id device_id;
+ cl_context context;
+
+ // input
+ Transform transform;
+ int transformed_width, transformed_height;
+ cl_mem transformed_y_cl, transformed_u_cl, transformed_v_cl;
+ LoadYUVState loadyuv;
+ cl_mem net_input;
+ size_t net_input_size;
+} ModelInput;
+
+void model_input_init(ModelInput* s, int width, int height,
+ cl_device_id device_id, cl_context context);
+float *model_input_prepare(ModelInput* s, cl_command_queue q,
+ cl_mem yuv_cl, int width, int height,
+ mat3 transform);
+void model_input_free(ModelInput* s);
+
+void model_publish(void* sock, uint32_t frame_id,
+ const mat3 transform, const ModelData data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/selfdrive/visiond/constants.py b/selfdrive/visiond/constants.py
new file mode 100644
index 00000000000000..878478e9cf1531
--- /dev/null
+++ b/selfdrive/visiond/constants.py
@@ -0,0 +1,2 @@
+MAX_DISTANCE = 140.
+LANE_OFFSET = 1.8
diff --git a/selfdrive/visiond/debayer.cl b/selfdrive/visiond/debayer.cl
new file mode 100644
index 00000000000000..344ead035672ec
--- /dev/null
+++ b/selfdrive/visiond/debayer.cl
@@ -0,0 +1,130 @@
+const __constant float3 color_correction[3] = {
+ // Matrix from WBraw -> sRGBD65 (normalized)
+ (float3)( 1.62393627, -0.2092988, 0.00119886),
+ (float3)(-0.45734315, 1.5534676, -0.59296798),
+ (float3)(-0.16659312, -0.3441688, 1.59176912),
+};
+
+float3 color_correct(float3 x) {
+ float3 ret = (0,0,0);
+
+ // white balance of daylight
+ x /= (float3)(0.4609375, 1.0, 0.546875);
+ x = max(0.0, min(1.0, x));
+
+ // fix up the colors
+ ret += x.x * color_correction[0];
+ ret += x.y * color_correction[1];
+ ret += x.z * color_correction[2];
+ return ret;
+}
+
+float3 srgb_gamma(float3 p) {
+ // go all out and add an sRGB gamma curve
+ const float3 ph = (1.0f + 0.055f)*pow(p, 1/2.4f) - 0.055f;
+ const float3 pl = p*12.92f;
+ return select(ph, pl, islessequal(p, 0.0031308f));
+}
+
+__constant int dpcm_lookup[512] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, 935, 951, 967, 983, 999, 1015, 1031, 1047, 1063, 1079, 1095, 1111, 1127, 1143, 1159, 1175, 1191, 1207, 1223, 1239, 1255, 1271, 1287, 1303, 1319, 1335, 1351, 1367, 1383, 1399, 1415, 1431, -935, -951, -967, -983, -999, -1015, -1031, -1047, -1063, -1079, -1095, -1111, -1127, -1143, -1159, -1175, -1191, -1207, -1223, -1239, -1255, -1271, -1287, -1303, -1319, -1335, -1351, -1367, -1383, -1399, -1415, -1431, 419, 427, 435, 443, 451, 459, 467, 475, 483, 491, 499, 507, 515, 523, 531, 539, 547, 555, 563, 571, 579, 587, 595, 603, 611, 619, 627, 635, 643, 651, 659, 667, 675, 683, 691, 699, 707, 715, 723, 731, 739, 747, 755, 763, 771, 779, 787, 795, 803, 811, 819, 827, 835, 843, 851, 859, 867, 875, 883, 891, 899, 907, 915, 923, -419, -427, -435, -443, -451, -459, -467, -475, -483, -491, -499, -507, -515, -523, -531, -539, -547, -555, -563, -571, -579, -587, -595, -603, -611, -619, -627, -635, -643, -651, -659, -667, -675, -683, -691, -699, -707, -715, -723, -731, -739, -747, -755, -763, -771, -779, -787, -795, -803, -811, -819, -827, -835, -843, -851, -859, -867, -875, -883, -891, -899, -907, -915, -923, 161, 165, 169, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313, 317, 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 365, 369, 373, 377, 381, 385, 389, 393, 397, 401, 405, 409, 413, -161, -165, -169, -173, -177, -181, -185, -189, -193, -197, -201, -205, -209, -213, -217, -221, -225, -229, -233, -237, -241, -245, -249, -253, -257, -261, -265, -269, -273, -277, -281, -285, -289, -293, -297, -301, -305, -309, -313, -317, -321, -325, -329, -333, -337, -341, -345, -349, -353, -357, -361, -365, -369, -373, -377, -381, -385, -389, -393, -397, -401, -405, -409, -413, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, -32, -34, -36, -38, -40, -42, -44, -46, -48, -50, -52, -54, -56, -58, -60, -62, -64, -66, -68, -70, -72, -74, -76, -78, -80, -82, -84, -86, -88, -90, -92, -94, -96, -98, -100, -102, -104, -106, -108, -110, -112, -114, -116, -118, -120, -122, -124, -126, -128, -130, -132, -134, -136, -138, -140, -142, -144, -146, -148, -150, -152, -154, -156, -158};
+
+inline uint4 decompress(uint4 p, uint4 pl) {
+ uint4 r1 = (pl + (uint4)(dpcm_lookup[p.s0], dpcm_lookup[p.s1], dpcm_lookup[p.s2], dpcm_lookup[p.s3]));
+ uint4 r2 = ((p-0x200)<<5) | 0xF;
+ r2 += select((uint4)(0,0,0,0), (uint4)(1,1,1,1), r2 <= pl);
+ return select(r2, r1, p < 0x200);
+}
+
+__kernel void debayer10(__global uchar const * const in,
+ __global uchar * out, float digital_gain)
+{
+ const int oy = get_global_id(0);
+ if (oy >= RGB_HEIGHT) return;
+ const int iy = oy * 2;
+
+ uint4 pint_last;
+ for (int ox = 0; ox < RGB_WIDTH; ox += 2) {
+ const int ix = (ox/2) * 5;
+
+ // TODO: why doesn't this work for the frontview
+ /*const uchar8 v1 = vload8(0, &in[iy * FRAME_STRIDE + ix]);
+ const uchar ex1 = v1.s4;
+ const uchar8 v2 = vload8(0, &in[(iy+1) * FRAME_STRIDE + ix]);
+ const uchar ex2 = v2.s4;*/
+
+ const uchar4 v1 = vload4(0, &in[iy * FRAME_STRIDE + ix]);
+ const uchar ex1 = in[iy * FRAME_STRIDE + ix + 4];
+ const uchar4 v2 = vload4(0, &in[(iy+1) * FRAME_STRIDE + ix]);
+ const uchar ex2 = in[(iy+1) * FRAME_STRIDE + ix + 4];
+
+ uint4 pinta[2];
+ pinta[0] = (uint4)(
+ (((uint)v1.s0 << 2) + ( (ex1 >> 0) & 3)),
+ (((uint)v1.s1 << 2) + ( (ex1 >> 2) & 3)),
+ (((uint)v2.s0 << 2) + ( (ex2 >> 0) & 3)),
+ (((uint)v2.s1 << 2) + ( (ex2 >> 2) & 3)));
+ pinta[1] = (uint4)(
+ (((uint)v1.s2 << 2) + ( (ex1 >> 4) & 3)),
+ (((uint)v1.s3 << 2) + ( (ex1 >> 6) & 3)),
+ (((uint)v2.s2 << 2) + ( (ex2 >> 4) & 3)),
+ (((uint)v2.s3 << 2) + ( (ex2 >> 6) & 3)));
+
+ #pragma unroll
+ for (uint px = 0; px < 2; px++) {
+ uint4 pint = pinta[px];
+
+#if HDR
+ // decompress HDR
+ pint = (ox == 0 && px == 0) ? ((pint<<4) | 8) : decompress(pint, pint_last);
+ pint_last = pint;
+#endif
+
+ float4 p = convert_float4(pint);
+
+ // 64 is the black level of the sensor, remove
+ // (changed to 56 for HDR)
+ const float black_level = 56.0f;
+ p = (p - black_level);
+
+ // correct vignetting (no pow function?)
+ // see https://www.eecis.udel.edu/~jye/lab_research/09/JiUp.pdf the A (4th order)
+ const float r = ((oy - RGB_HEIGHT/2)*(oy - RGB_HEIGHT/2) + (ox - RGB_WIDTH/2)*(ox - RGB_WIDTH/2));
+ const float fake_f = 700.0f; // should be 910, but this fits...
+ const float lil_a = (1.0f + r/(fake_f*fake_f));
+ p = p * lil_a * lil_a;
+
+ // rescale to 1.0
+#if HDR
+ p /= (16384.0f-black_level);
+#else
+ p /= (1024.0f-black_level);
+#endif
+
+ // digital gain
+ p *= digital_gain;
+
+ // use both green channels
+#if BAYER_FLIP == 3
+ float3 c1 = (float3)(p.s3, (p.s1+p.s2)/2.0f, p.s0);
+#elif BAYER_FLIP == 2
+ float3 c1 = (float3)(p.s2, (p.s0+p.s3)/2.0f, p.s1);
+#elif BAYER_FLIP == 1
+ float3 c1 = (float3)(p.s1, (p.s0+p.s3)/2.0f, p.s2);
+#elif BAYER_FLIP == 0
+ float3 c1 = (float3)(p.s0, (p.s1+p.s2)/2.0f, p.s3);
+#endif
+
+ // color correction
+ c1 = color_correct(c1);
+
+#if HDR
+ // srgb gamma isn't right for YUV, so it's disabled for now
+ c1 = srgb_gamma(c1);
+#endif
+
+ // output BGR
+ const int ooff = oy * RGB_STRIDE/3 + ox;
+ vstore3(convert_uchar3_sat(c1.zyx * 255.0f), ooff+px, out);
+ }
+ }
+}
diff --git a/selfdrive/visiond/include/msm_cam_sensor.h b/selfdrive/visiond/include/msm_cam_sensor.h
new file mode 100644
index 00000000000000..c75d1fd5272444
--- /dev/null
+++ b/selfdrive/visiond/include/msm_cam_sensor.h
@@ -0,0 +1,829 @@
+#ifndef __LINUX_MSM_CAM_SENSOR_H
+#define __LINUX_MSM_CAM_SENSOR_H
+
+#ifdef MSM_CAMERA_BIONIC
+#include
+#endif
+
+//#include
+#include "msm_camsensor_sdk.h"
+
+#include
+#include
+#ifdef CONFIG_COMPAT
+#include
+#endif
+
+#define I2C_SEQ_REG_SETTING_MAX 5
+
+#define MSM_SENSOR_MCLK_8HZ 8000000
+#define MSM_SENSOR_MCLK_16HZ 16000000
+#define MSM_SENSOR_MCLK_24HZ 24000000
+
+#define MAX_SENSOR_NAME 32
+#define MAX_ACTUATOR_AF_TOTAL_STEPS 1024
+
+#define MAX_OIS_MOD_NAME_SIZE 32
+#define MAX_OIS_NAME_SIZE 32
+#define MAX_OIS_REG_SETTINGS 800
+
+#define MOVE_NEAR 0
+#define MOVE_FAR 1
+
+#define MSM_ACTUATOR_MOVE_SIGNED_FAR -1
+#define MSM_ACTUATOR_MOVE_SIGNED_NEAR 1
+
+#define MAX_ACTUATOR_REGION 5
+
+#define MAX_EEPROM_NAME 32
+
+#define MAX_AF_ITERATIONS 3
+#define MAX_NUMBER_OF_STEPS 47
+#define MAX_REGULATOR 5
+
+#define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */
+#define MSM_V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4')
+ /* 14 BGBG.. GRGR.. */
+#define MSM_V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4')
+ /* 14 GBGB.. RGRG.. */
+#define MSM_V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4')
+ /* 14 GRGR.. BGBG.. */
+#define MSM_V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4')
+ /* 14 RGRG.. GBGB.. */
+
+enum flash_type {
+ LED_FLASH = 1,
+ STROBE_FLASH,
+ GPIO_FLASH
+};
+
+enum msm_sensor_resolution_t {
+ MSM_SENSOR_RES_FULL,
+ MSM_SENSOR_RES_QTR,
+ MSM_SENSOR_RES_2,
+ MSM_SENSOR_RES_3,
+ MSM_SENSOR_RES_4,
+ MSM_SENSOR_RES_5,
+ MSM_SENSOR_RES_6,
+ MSM_SENSOR_RES_7,
+ MSM_SENSOR_INVALID_RES,
+};
+
+enum msm_camera_stream_type_t {
+ MSM_CAMERA_STREAM_PREVIEW,
+ MSM_CAMERA_STREAM_SNAPSHOT,
+ MSM_CAMERA_STREAM_VIDEO,
+ MSM_CAMERA_STREAM_INVALID,
+};
+
+enum sensor_sub_module_t {
+ SUB_MODULE_SENSOR,
+ SUB_MODULE_CHROMATIX,
+ SUB_MODULE_ACTUATOR,
+ SUB_MODULE_EEPROM,
+ SUB_MODULE_LED_FLASH,
+ SUB_MODULE_STROBE_FLASH,
+ SUB_MODULE_CSID,
+ SUB_MODULE_CSID_3D,
+ SUB_MODULE_CSIPHY,
+ SUB_MODULE_CSIPHY_3D,
+ SUB_MODULE_OIS,
+ SUB_MODULE_EXT,
+ SUB_MODULE_MAX,
+};
+
+enum {
+ MSM_CAMERA_EFFECT_MODE_OFF,
+ MSM_CAMERA_EFFECT_MODE_MONO,
+ MSM_CAMERA_EFFECT_MODE_NEGATIVE,
+ MSM_CAMERA_EFFECT_MODE_SOLARIZE,
+ MSM_CAMERA_EFFECT_MODE_SEPIA,
+ MSM_CAMERA_EFFECT_MODE_POSTERIZE,
+ MSM_CAMERA_EFFECT_MODE_WHITEBOARD,
+ MSM_CAMERA_EFFECT_MODE_BLACKBOARD,
+ MSM_CAMERA_EFFECT_MODE_AQUA,
+ MSM_CAMERA_EFFECT_MODE_EMBOSS,
+ MSM_CAMERA_EFFECT_MODE_SKETCH,
+ MSM_CAMERA_EFFECT_MODE_NEON,
+ MSM_CAMERA_EFFECT_MODE_MAX
+};
+
+enum {
+ MSM_CAMERA_WB_MODE_AUTO,
+ MSM_CAMERA_WB_MODE_CUSTOM,
+ MSM_CAMERA_WB_MODE_INCANDESCENT,
+ MSM_CAMERA_WB_MODE_FLUORESCENT,
+ MSM_CAMERA_WB_MODE_WARM_FLUORESCENT,
+ MSM_CAMERA_WB_MODE_DAYLIGHT,
+ MSM_CAMERA_WB_MODE_CLOUDY_DAYLIGHT,
+ MSM_CAMERA_WB_MODE_TWILIGHT,
+ MSM_CAMERA_WB_MODE_SHADE,
+ MSM_CAMERA_WB_MODE_OFF,
+ MSM_CAMERA_WB_MODE_MAX
+};
+
+enum {
+ MSM_CAMERA_SCENE_MODE_OFF,
+ MSM_CAMERA_SCENE_MODE_AUTO,
+ MSM_CAMERA_SCENE_MODE_LANDSCAPE,
+ MSM_CAMERA_SCENE_MODE_SNOW,
+ MSM_CAMERA_SCENE_MODE_BEACH,
+ MSM_CAMERA_SCENE_MODE_SUNSET,
+ MSM_CAMERA_SCENE_MODE_NIGHT,
+ MSM_CAMERA_SCENE_MODE_PORTRAIT,
+ MSM_CAMERA_SCENE_MODE_BACKLIGHT,
+ MSM_CAMERA_SCENE_MODE_SPORTS,
+ MSM_CAMERA_SCENE_MODE_ANTISHAKE,
+ MSM_CAMERA_SCENE_MODE_FLOWERS,
+ MSM_CAMERA_SCENE_MODE_CANDLELIGHT,
+ MSM_CAMERA_SCENE_MODE_FIREWORKS,
+ MSM_CAMERA_SCENE_MODE_PARTY,
+ MSM_CAMERA_SCENE_MODE_NIGHT_PORTRAIT,
+ MSM_CAMERA_SCENE_MODE_THEATRE,
+ MSM_CAMERA_SCENE_MODE_ACTION,
+ MSM_CAMERA_SCENE_MODE_AR,
+ MSM_CAMERA_SCENE_MODE_FACE_PRIORITY,
+ MSM_CAMERA_SCENE_MODE_BARCODE,
+ MSM_CAMERA_SCENE_MODE_HDR,
+ MSM_CAMERA_SCENE_MODE_MAX
+};
+
+enum csid_cfg_type_t {
+ CSID_INIT,
+ CSID_CFG,
+ CSID_TESTMODE_CFG,
+ CSID_RELEASE,
+};
+
+enum csiphy_cfg_type_t {
+ CSIPHY_INIT,
+ CSIPHY_CFG,
+ CSIPHY_RELEASE,
+};
+
+enum camera_vreg_type {
+ VREG_TYPE_DEFAULT,
+ VREG_TYPE_CUSTOM,
+};
+
+enum sensor_af_t {
+ SENSOR_AF_FOCUSSED,
+ SENSOR_AF_NOT_FOCUSSED,
+};
+
+enum cci_i2c_master_t {
+ MASTER_0,
+ MASTER_1,
+ MASTER_MAX,
+};
+
+struct msm_camera_i2c_array_write_config {
+ struct msm_camera_i2c_reg_setting conf_array;
+ uint16_t slave_addr;
+};
+
+struct msm_camera_i2c_read_config {
+ uint16_t slave_addr;
+ uint16_t reg_addr;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ enum msm_camera_i2c_data_type data_type;
+ uint16_t data;
+};
+
+struct msm_camera_csi2_params {
+ struct msm_camera_csid_params csid_params;
+ struct msm_camera_csiphy_params csiphy_params;
+ uint8_t csi_clk_scale_enable;
+};
+
+struct msm_camera_csi_lane_params {
+ uint16_t csi_lane_assign;
+ uint16_t csi_lane_mask;
+};
+
+struct csi_lane_params_t {
+ uint16_t csi_lane_assign;
+ uint8_t csi_lane_mask;
+ uint8_t csi_if;
+ int8_t csid_core[2];
+ uint8_t csi_phy_sel;
+};
+
+struct msm_sensor_info_t {
+ char sensor_name[MAX_SENSOR_NAME];
+ uint32_t session_id;
+ int32_t subdev_id[SUB_MODULE_MAX];
+ int32_t subdev_intf[SUB_MODULE_MAX];
+ uint8_t is_mount_angle_valid;
+ uint32_t sensor_mount_angle;
+ int modes_supported;
+ enum camb_position_t position;
+};
+
+struct camera_vreg_t {
+ const char *reg_name;
+ int min_voltage;
+ int max_voltage;
+ int op_mode;
+ uint32_t delay;
+ const char *custom_vreg_name;
+ enum camera_vreg_type type;
+};
+
+struct sensorb_cfg_data {
+ int cfgtype;
+ union {
+ struct msm_sensor_info_t sensor_info;
+ struct msm_sensor_init_params sensor_init_params;
+ void *setting;
+ struct msm_sensor_i2c_sync_params sensor_i2c_sync_params;
+ } cfg;
+};
+
+struct csid_cfg_data {
+ enum csid_cfg_type_t cfgtype;
+ union {
+ uint32_t csid_version;
+ struct msm_camera_csid_params *csid_params;
+ struct msm_camera_csid_testmode_parms *csid_testmode_params;
+ } cfg;
+};
+
+struct csiphy_cfg_data {
+ enum csiphy_cfg_type_t cfgtype;
+ union {
+ struct msm_camera_csiphy_params *csiphy_params;
+ struct msm_camera_csi_lane_params *csi_lane_params;
+ } cfg;
+};
+
+enum eeprom_cfg_type_t {
+ CFG_EEPROM_GET_INFO,
+ CFG_EEPROM_GET_CAL_DATA,
+ CFG_EEPROM_READ_CAL_DATA,
+ CFG_EEPROM_WRITE_DATA,
+ CFG_EEPROM_GET_MM_INFO,
+ CFG_EEPROM_INIT,
+};
+
+struct eeprom_get_t {
+ uint32_t num_bytes;
+};
+
+struct eeprom_read_t {
+ uint8_t *dbuffer;
+ uint32_t num_bytes;
+};
+
+struct eeprom_write_t {
+ uint8_t *dbuffer;
+ uint32_t num_bytes;
+};
+
+struct eeprom_get_cmm_t {
+ uint32_t cmm_support;
+ uint32_t cmm_compression;
+ uint32_t cmm_size;
+};
+
+struct msm_eeprom_info_t {
+ struct msm_sensor_power_setting_array *power_setting_array;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ struct msm_eeprom_memory_map_array *mem_map_array;
+};
+
+struct msm_eeprom_cfg_data {
+ enum eeprom_cfg_type_t cfgtype;
+ uint8_t is_supported;
+ union {
+ char eeprom_name[MAX_SENSOR_NAME];
+ struct eeprom_get_t get_data;
+ struct eeprom_read_t read_data;
+ struct eeprom_write_t write_data;
+ struct eeprom_get_cmm_t get_cmm_data;
+ struct msm_eeprom_info_t eeprom_info;
+ } cfg;
+};
+
+#ifdef CONFIG_COMPAT
+struct msm_sensor_power_setting32 {
+ enum msm_sensor_power_seq_type_t seq_type;
+ uint16_t seq_val;
+ compat_uint_t config_val;
+ uint16_t delay;
+ compat_uptr_t data[10];
+};
+
+struct msm_sensor_power_setting_array32 {
+ struct msm_sensor_power_setting32 power_setting_a[MAX_POWER_CONFIG];
+ compat_uptr_t power_setting;
+ uint16_t size;
+ struct msm_sensor_power_setting32
+ power_down_setting_a[MAX_POWER_CONFIG];
+ compat_uptr_t power_down_setting;
+ uint16_t size_down;
+};
+
+struct msm_camera_sensor_slave_info32 {
+ char sensor_name[32];
+ char eeprom_name[32];
+ char actuator_name[32];
+ char ois_name[32];
+ char flash_name[32];
+ enum msm_sensor_camera_id_t camera_id;
+ uint16_t slave_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ struct msm_sensor_id_info_t sensor_id_info;
+ struct msm_sensor_power_setting_array32 power_setting_array;
+ uint8_t is_init_params_valid;
+ struct msm_sensor_init_params sensor_init_params;
+ enum msm_sensor_output_format_t output_format;
+};
+
+struct msm_camera_csid_lut_params32 {
+ uint8_t num_cid;
+ struct msm_camera_csid_vc_cfg vc_cfg_a[MAX_CID];
+ compat_uptr_t vc_cfg[MAX_CID];
+};
+
+struct msm_camera_csid_params32 {
+ uint8_t lane_cnt;
+ uint16_t lane_assign;
+ uint8_t phy_sel;
+ uint32_t csi_clk;
+ struct msm_camera_csid_lut_params32 lut_params;
+ uint8_t csi_3p_sel;
+};
+
+struct msm_camera_csi2_params32 {
+ struct msm_camera_csid_params32 csid_params;
+ struct msm_camera_csiphy_params csiphy_params;
+ uint8_t csi_clk_scale_enable;
+};
+
+struct csid_cfg_data32 {
+ enum csid_cfg_type_t cfgtype;
+ union {
+ uint32_t csid_version;
+ compat_uptr_t csid_params;
+ compat_uptr_t csid_testmode_params;
+ } cfg;
+};
+
+struct eeprom_read_t32 {
+ compat_uptr_t dbuffer;
+ uint32_t num_bytes;
+};
+
+struct eeprom_write_t32 {
+ compat_uptr_t dbuffer;
+ uint32_t num_bytes;
+};
+
+struct msm_eeprom_info_t32 {
+ compat_uptr_t power_setting_array;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ compat_uptr_t mem_map_array;
+};
+
+struct msm_eeprom_cfg_data32 {
+ enum eeprom_cfg_type_t cfgtype;
+ uint8_t is_supported;
+ union {
+ char eeprom_name[MAX_SENSOR_NAME];
+ struct eeprom_get_t get_data;
+ struct eeprom_read_t32 read_data;
+ struct eeprom_write_t32 write_data;
+ struct msm_eeprom_info_t32 eeprom_info;
+ } cfg;
+};
+
+struct msm_camera_i2c_seq_reg_setting32 {
+ compat_uptr_t reg_setting;
+ uint16_t size;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ uint16_t delay;
+};
+#endif
+
+enum msm_sensor_cfg_type_t {
+ CFG_SET_SLAVE_INFO,
+ CFG_SLAVE_READ_I2C,
+ CFG_WRITE_I2C_ARRAY,
+ CFG_SLAVE_WRITE_I2C_ARRAY,
+ CFG_WRITE_I2C_SEQ_ARRAY,
+ CFG_POWER_UP,
+ CFG_POWER_DOWN,
+ CFG_SET_STOP_STREAM_SETTING,
+ CFG_GET_SENSOR_INFO,
+ CFG_GET_SENSOR_INIT_PARAMS,
+ CFG_SET_INIT_SETTING,
+ CFG_SET_RESOLUTION,
+ CFG_SET_STOP_STREAM,
+ CFG_SET_START_STREAM,
+ CFG_SET_SATURATION,
+ CFG_SET_CONTRAST,
+ CFG_SET_SHARPNESS,
+ CFG_SET_ISO,
+ CFG_SET_EXPOSURE_COMPENSATION,
+ CFG_SET_ANTIBANDING,
+ CFG_SET_BESTSHOT_MODE,
+ CFG_SET_EFFECT,
+ CFG_SET_WHITE_BALANCE,
+ CFG_SET_AUTOFOCUS,
+ CFG_CANCEL_AUTOFOCUS,
+ CFG_SET_STREAM_TYPE,
+ CFG_SET_I2C_SYNC_PARAM,
+ CFG_WRITE_I2C_ARRAY_ASYNC,
+ CFG_WRITE_I2C_ARRAY_SYNC,
+ CFG_WRITE_I2C_ARRAY_SYNC_BLOCK,
+};
+
+enum msm_actuator_cfg_type_t {
+ CFG_GET_ACTUATOR_INFO,
+ CFG_SET_ACTUATOR_INFO,
+ CFG_SET_DEFAULT_FOCUS,
+ CFG_MOVE_FOCUS,
+ CFG_SET_POSITION,
+ CFG_ACTUATOR_POWERDOWN,
+ CFG_ACTUATOR_POWERUP,
+ CFG_ACTUATOR_INIT,
+};
+
+enum msm_ois_cfg_type_t {
+ CFG_OIS_INIT,
+ CFG_OIS_POWERDOWN,
+ CFG_OIS_POWERUP,
+ CFG_OIS_CONTROL,
+ CFG_OIS_I2C_WRITE_SEQ_TABLE,
+};
+
+enum msm_ois_i2c_operation {
+ MSM_OIS_WRITE = 0,
+ MSM_OIS_POLL,
+};
+
+struct reg_settings_ois_t {
+ uint16_t reg_addr;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ uint32_t reg_data;
+ enum msm_camera_i2c_data_type data_type;
+ enum msm_ois_i2c_operation i2c_operation;
+ uint32_t delay;
+#define OIS_REG_DATA_SEQ_MAX 128
+ unsigned char reg_data_seq[OIS_REG_DATA_SEQ_MAX];
+ uint32_t reg_data_seq_size;
+};
+
+struct msm_ois_params_t {
+ uint16_t data_size;
+ uint16_t setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type i2c_addr_type;
+ enum msm_camera_i2c_data_type i2c_data_type;
+ struct reg_settings_ois_t *settings;
+};
+
+struct msm_ois_set_info_t {
+ struct msm_ois_params_t ois_params;
+};
+
+struct msm_actuator_move_params_t {
+ int8_t dir;
+ int8_t sign_dir;
+ int16_t dest_step_pos;
+ int32_t num_steps;
+ uint16_t curr_lens_pos;
+ struct damping_params_t *ringing_params;
+};
+
+struct msm_actuator_tuning_params_t {
+ int16_t initial_code;
+ uint16_t pwd_step;
+ uint16_t region_size;
+ uint32_t total_steps;
+ struct region_params_t *region_params;
+};
+
+struct park_lens_data_t {
+ uint32_t damping_step;
+ uint32_t damping_delay;
+ uint32_t hw_params;
+ uint32_t max_step;
+};
+
+struct msm_actuator_params_t {
+ enum actuator_type act_type;
+ uint8_t reg_tbl_size;
+ uint16_t data_size;
+ uint16_t init_setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_actuator_addr_type i2c_addr_type;
+ enum msm_actuator_data_type i2c_data_type;
+ struct msm_actuator_reg_params_t *reg_tbl_params;
+ struct reg_settings_t *init_settings;
+ struct park_lens_data_t park_lens;
+};
+
+struct msm_actuator_set_info_t {
+ struct msm_actuator_params_t actuator_params;
+ struct msm_actuator_tuning_params_t af_tuning_params;
+};
+
+struct msm_actuator_get_info_t {
+ uint32_t focal_length_num;
+ uint32_t focal_length_den;
+ uint32_t f_number_num;
+ uint32_t f_number_den;
+ uint32_t f_pix_num;
+ uint32_t f_pix_den;
+ uint32_t total_f_dist_num;
+ uint32_t total_f_dist_den;
+ uint32_t hor_view_angle_num;
+ uint32_t hor_view_angle_den;
+ uint32_t ver_view_angle_num;
+ uint32_t ver_view_angle_den;
+};
+
+enum af_camera_name {
+ ACTUATOR_MAIN_CAM_0,
+ ACTUATOR_MAIN_CAM_1,
+ ACTUATOR_MAIN_CAM_2,
+ ACTUATOR_MAIN_CAM_3,
+ ACTUATOR_MAIN_CAM_4,
+ ACTUATOR_MAIN_CAM_5,
+ ACTUATOR_WEB_CAM_0,
+ ACTUATOR_WEB_CAM_1,
+ ACTUATOR_WEB_CAM_2,
+};
+
+struct msm_ois_cfg_data {
+ int cfgtype;
+ union {
+ struct msm_ois_set_info_t set_info;
+ struct msm_camera_i2c_seq_reg_setting *settings;
+ } cfg;
+};
+
+struct msm_actuator_set_position_t {
+ uint16_t number_of_steps;
+ uint32_t hw_params;
+ uint16_t pos[MAX_NUMBER_OF_STEPS];
+ uint16_t delay[MAX_NUMBER_OF_STEPS];
+};
+
+struct msm_actuator_cfg_data {
+ int cfgtype;
+ uint8_t is_af_supported;
+ union {
+ struct msm_actuator_move_params_t move;
+ struct msm_actuator_set_info_t set_info;
+ struct msm_actuator_get_info_t get_info;
+ struct msm_actuator_set_position_t setpos;
+ enum af_camera_name cam_name;
+ } cfg;
+};
+
+enum msm_camera_led_config_t {
+ MSM_CAMERA_LED_OFF,
+ MSM_CAMERA_LED_LOW,
+ MSM_CAMERA_LED_HIGH,
+ MSM_CAMERA_LED_INIT,
+ MSM_CAMERA_LED_RELEASE,
+};
+
+struct msm_camera_led_cfg_t {
+ enum msm_camera_led_config_t cfgtype;
+ int32_t torch_current[MAX_LED_TRIGGERS];
+ int32_t flash_current[MAX_LED_TRIGGERS];
+ int32_t flash_duration[MAX_LED_TRIGGERS];
+};
+
+struct msm_flash_init_info_t {
+ enum msm_flash_driver_type flash_driver_type;
+ uint32_t slave_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ struct msm_sensor_power_setting_array *power_setting_array;
+ struct msm_camera_i2c_reg_setting_array *settings;
+};
+
+struct msm_flash_cfg_data_t {
+ enum msm_flash_cfg_type_t cfg_type;
+ int32_t flash_current[MAX_LED_TRIGGERS];
+ int32_t flash_duration[MAX_LED_TRIGGERS];
+ union {
+ struct msm_flash_init_info_t *flash_init_info;
+ struct msm_camera_i2c_reg_setting_array *settings;
+ } cfg;
+};
+
+/* sensor init structures and enums */
+enum msm_sensor_init_cfg_type_t {
+ CFG_SINIT_PROBE,
+ CFG_SINIT_PROBE_DONE,
+ CFG_SINIT_PROBE_WAIT_DONE,
+};
+
+struct sensor_init_cfg_data {
+ enum msm_sensor_init_cfg_type_t cfgtype;
+ struct msm_sensor_info_t probed_info;
+ char entity_name[MAX_SENSOR_NAME];
+ union {
+ void *setting;
+ } cfg;
+};
+
+#define VIDIOC_MSM_SENSOR_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data)
+
+#define VIDIOC_MSM_SENSOR_RELEASE \
+ _IO('V', BASE_VIDIOC_PRIVATE + 2)
+
+#define VIDIOC_MSM_SENSOR_GET_SUBDEV_ID \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 3, uint32_t)
+
+#define VIDIOC_MSM_CSIPHY_IO_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data)
+
+#define VIDIOC_MSM_CSID_IO_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data)
+
+#define VIDIOC_MSM_ACTUATOR_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data)
+
+#define VIDIOC_MSM_FLASH_LED_DATA_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_led_cfg_t)
+
+#define VIDIOC_MSM_EEPROM_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data)
+
+#define VIDIOC_MSM_SENSOR_GET_AF_STATUS \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 9, uint32_t)
+
+#define VIDIOC_MSM_SENSOR_INIT_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data)
+
+#define VIDIOC_MSM_OIS_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data)
+
+#define VIDIOC_MSM_FLASH_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_flash_cfg_data_t)
+
+#ifdef CONFIG_COMPAT
+struct msm_camera_i2c_reg_setting32 {
+ compat_uptr_t reg_setting;
+ uint16_t size;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ enum msm_camera_i2c_data_type data_type;
+ uint16_t delay;
+};
+
+struct msm_camera_i2c_array_write_config32 {
+ struct msm_camera_i2c_reg_setting32 conf_array;
+ uint16_t slave_addr;
+};
+
+struct msm_actuator_tuning_params_t32 {
+ int16_t initial_code;
+ uint16_t pwd_step;
+ uint16_t region_size;
+ uint32_t total_steps;
+ compat_uptr_t region_params;
+};
+
+struct msm_actuator_params_t32 {
+ enum actuator_type act_type;
+ uint8_t reg_tbl_size;
+ uint16_t data_size;
+ uint16_t init_setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_actuator_addr_type i2c_addr_type;
+ enum msm_actuator_data_type i2c_data_type;
+ compat_uptr_t reg_tbl_params;
+ compat_uptr_t init_settings;
+ struct park_lens_data_t park_lens;
+};
+
+struct msm_actuator_set_info_t32 {
+ struct msm_actuator_params_t32 actuator_params;
+ struct msm_actuator_tuning_params_t32 af_tuning_params;
+};
+
+struct sensor_init_cfg_data32 {
+ enum msm_sensor_init_cfg_type_t cfgtype;
+ struct msm_sensor_info_t probed_info;
+ char entity_name[MAX_SENSOR_NAME];
+ union {
+ compat_uptr_t setting;
+ } cfg;
+};
+
+struct msm_actuator_move_params_t32 {
+ int8_t dir;
+ int8_t sign_dir;
+ int16_t dest_step_pos;
+ int32_t num_steps;
+ uint16_t curr_lens_pos;
+ compat_uptr_t ringing_params;
+};
+
+struct msm_actuator_cfg_data32 {
+ int cfgtype;
+ uint8_t is_af_supported;
+ union {
+ struct msm_actuator_move_params_t32 move;
+ struct msm_actuator_set_info_t32 set_info;
+ struct msm_actuator_get_info_t get_info;
+ struct msm_actuator_set_position_t setpos;
+ enum af_camera_name cam_name;
+ } cfg;
+};
+
+struct csiphy_cfg_data32 {
+ enum csiphy_cfg_type_t cfgtype;
+ union {
+ compat_uptr_t csiphy_params;
+ compat_uptr_t csi_lane_params;
+ } cfg;
+};
+
+struct sensorb_cfg_data32 {
+ int cfgtype;
+ union {
+ struct msm_sensor_info_t sensor_info;
+ struct msm_sensor_init_params sensor_init_params;
+ compat_uptr_t setting;
+ struct msm_sensor_i2c_sync_params sensor_i2c_sync_params;
+ } cfg;
+};
+
+struct msm_ois_params_t32 {
+ uint16_t data_size;
+ uint16_t setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type i2c_addr_type;
+ enum msm_camera_i2c_data_type i2c_data_type;
+ compat_uptr_t settings;
+};
+
+struct msm_ois_set_info_t32 {
+ struct msm_ois_params_t32 ois_params;
+};
+
+struct msm_ois_cfg_data32 {
+ int cfgtype;
+ union {
+ struct msm_ois_set_info_t32 set_info;
+ compat_uptr_t settings;
+ } cfg;
+};
+
+struct msm_flash_init_info_t32 {
+ enum msm_flash_driver_type flash_driver_type;
+ uint32_t slave_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ compat_uptr_t power_setting_array;
+ compat_uptr_t settings;
+};
+
+struct msm_flash_cfg_data_t32 {
+ enum msm_flash_cfg_type_t cfg_type;
+ int32_t flash_current[MAX_LED_TRIGGERS];
+ int32_t flash_duration[MAX_LED_TRIGGERS];
+ union {
+ compat_uptr_t flash_init_info;
+ compat_uptr_t settings;
+ } cfg;
+};
+
+#define VIDIOC_MSM_ACTUATOR_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data32)
+
+#define VIDIOC_MSM_SENSOR_INIT_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data32)
+
+#define VIDIOC_MSM_CSIPHY_IO_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data32)
+
+#define VIDIOC_MSM_SENSOR_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data32)
+
+#define VIDIOC_MSM_EEPROM_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data32)
+
+#define VIDIOC_MSM_OIS_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data32)
+
+#define VIDIOC_MSM_CSID_IO_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data32)
+
+#define VIDIOC_MSM_FLASH_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_flash_cfg_data_t32)
+#endif
+
+#endif /* __LINUX_MSM_CAM_SENSOR_H */
diff --git a/selfdrive/visiond/include/msm_camsensor_sdk.h b/selfdrive/visiond/include/msm_camsensor_sdk.h
new file mode 100644
index 00000000000000..62a4da253c9345
--- /dev/null
+++ b/selfdrive/visiond/include/msm_camsensor_sdk.h
@@ -0,0 +1,386 @@
+#ifndef __LINUX_MSM_CAMSENSOR_SDK_H
+#define __LINUX_MSM_CAMSENSOR_SDK_H
+
+#define KVERSION 0x1
+
+#define MAX_POWER_CONFIG 12
+#define GPIO_OUT_LOW (0 << 1)
+#define GPIO_OUT_HIGH (1 << 1)
+#define CSI_EMBED_DATA 0x12
+#define CSI_RESERVED_DATA_0 0x13
+#define CSI_YUV422_8 0x1E
+#define CSI_RAW8 0x2A
+#define CSI_RAW10 0x2B
+#define CSI_RAW12 0x2C
+#define CSI_DECODE_6BIT 0
+#define CSI_DECODE_8BIT 1
+#define CSI_DECODE_10BIT 2
+#define CSI_DECODE_12BIT 3
+#define CSI_DECODE_DPCM_10_8_10 5
+#define MAX_CID 16
+#define I2C_SEQ_REG_DATA_MAX 1024
+#define I2C_REG_DATA_MAX (8*1024)
+
+#define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */
+#define MSM_V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4')
+ /* 14 BGBG.. GRGR.. */
+#define MSM_V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4')
+ /* 14 GBGB.. RGRG.. */
+#define MSM_V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4')
+ /* 14 GRGR.. BGBG.. */
+#define MSM_V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4')
+ /* 14 RGRG.. GBGB.. */
+
+#define MAX_ACTUATOR_REG_TBL_SIZE 8
+#define MAX_ACTUATOR_REGION 5
+#define NUM_ACTUATOR_DIR 2
+#define MAX_ACTUATOR_SCENARIO 8
+#define MAX_ACT_MOD_NAME_SIZE 32
+#define MAX_ACT_NAME_SIZE 32
+#define MAX_ACTUATOR_INIT_SET 120
+#define MAX_I2C_REG_SET 12
+
+#define MAX_LED_TRIGGERS 3
+
+#define MSM_EEPROM_MEMORY_MAP_MAX_SIZE 80
+#define MSM_EEPROM_MAX_MEM_MAP_CNT 8
+
+enum msm_sensor_camera_id_t {
+ CAMERA_0,
+ CAMERA_1,
+ CAMERA_2,
+ CAMERA_3,
+ MAX_CAMERAS,
+};
+
+enum i2c_freq_mode_t {
+ I2C_STANDARD_MODE,
+ I2C_FAST_MODE,
+ I2C_CUSTOM_MODE,
+ I2C_FAST_PLUS_MODE,
+ I2C_MAX_MODES,
+};
+
+enum camb_position_t {
+ BACK_CAMERA_B,
+ FRONT_CAMERA_B,
+ AUX_CAMERA_B = 0x100,
+ INVALID_CAMERA_B,
+};
+
+enum msm_sensor_power_seq_type_t {
+ SENSOR_CLK,
+ SENSOR_GPIO,
+ SENSOR_VREG,
+ SENSOR_I2C_MUX,
+ SENSOR_I2C,
+};
+
+enum msm_camera_i2c_reg_addr_type {
+ MSM_CAMERA_I2C_BYTE_ADDR = 1,
+ MSM_CAMERA_I2C_WORD_ADDR,
+ MSM_CAMERA_I2C_3B_ADDR,
+ MSM_CAMERA_I2C_ADDR_TYPE_MAX,
+};
+
+enum msm_camera_i2c_data_type {
+ MSM_CAMERA_I2C_BYTE_DATA = 1,
+ MSM_CAMERA_I2C_WORD_DATA,
+ MSM_CAMERA_I2C_DWORD_DATA,
+ MSM_CAMERA_I2C_SET_BYTE_MASK,
+ MSM_CAMERA_I2C_UNSET_BYTE_MASK,
+ MSM_CAMERA_I2C_SET_WORD_MASK,
+ MSM_CAMERA_I2C_UNSET_WORD_MASK,
+ MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA,
+ MSM_CAMERA_I2C_SEQ_DATA,
+ MSM_CAMERA_I2C_DATA_TYPE_MAX,
+};
+
+enum msm_sensor_power_seq_gpio_t {
+ SENSOR_GPIO_RESET,
+ SENSOR_GPIO_STANDBY,
+ SENSOR_GPIO_AF_PWDM,
+ SENSOR_GPIO_VIO,
+ SENSOR_GPIO_VANA,
+ SENSOR_GPIO_VDIG,
+ SENSOR_GPIO_VAF,
+ SENSOR_GPIO_FL_EN,
+ SENSOR_GPIO_FL_NOW,
+ SENSOR_GPIO_FL_RESET,
+ SENSOR_GPIO_CUSTOM1,
+ SENSOR_GPIO_CUSTOM2,
+ SENSOR_GPIO_MAX,
+};
+
+enum msm_camera_vreg_name_t {
+ CAM_VDIG,
+ CAM_VIO,
+ CAM_VANA,
+ CAM_VAF,
+ CAM_V_CUSTOM1,
+ CAM_V_CUSTOM2,
+ CAM_VREG_MAX,
+};
+
+enum msm_sensor_clk_type_t {
+ SENSOR_CAM_MCLK,
+ SENSOR_CAM_CLK,
+ SENSOR_CAM_CLK_MAX,
+};
+
+enum camerab_mode_t {
+ CAMERA_MODE_2D_B = (1<<0),
+ CAMERA_MODE_3D_B = (1<<1),
+ CAMERA_MODE_INVALID = (1<<2),
+};
+
+enum msm_actuator_data_type {
+ MSM_ACTUATOR_BYTE_DATA = 1,
+ MSM_ACTUATOR_WORD_DATA,
+};
+
+enum msm_actuator_addr_type {
+ MSM_ACTUATOR_BYTE_ADDR = 1,
+ MSM_ACTUATOR_WORD_ADDR,
+};
+
+enum msm_actuator_write_type {
+ MSM_ACTUATOR_WRITE_HW_DAMP,
+ MSM_ACTUATOR_WRITE_DAC,
+ MSM_ACTUATOR_WRITE,
+ MSM_ACTUATOR_WRITE_DIR_REG,
+ MSM_ACTUATOR_POLL,
+ MSM_ACTUATOR_READ_WRITE,
+};
+
+enum msm_actuator_i2c_operation {
+ MSM_ACT_WRITE = 0,
+ MSM_ACT_POLL,
+};
+
+enum actuator_type {
+ ACTUATOR_VCM,
+ ACTUATOR_PIEZO,
+ ACTUATOR_HVCM,
+ ACTUATOR_BIVCM,
+};
+
+enum msm_flash_driver_type {
+ FLASH_DRIVER_PMIC,
+ FLASH_DRIVER_I2C,
+ FLASH_DRIVER_GPIO,
+ FLASH_DRIVER_DEFAULT
+};
+
+enum msm_flash_cfg_type_t {
+ CFG_FLASH_INIT,
+ CFG_FLASH_RELEASE,
+ CFG_FLASH_OFF,
+ CFG_FLASH_LOW,
+ CFG_FLASH_HIGH,
+};
+
+enum msm_sensor_output_format_t {
+ MSM_SENSOR_BAYER,
+ MSM_SENSOR_YCBCR,
+ MSM_SENSOR_META,
+};
+
+struct msm_sensor_power_setting {
+ enum msm_sensor_power_seq_type_t seq_type;
+ unsigned short seq_val;
+ long config_val;
+ unsigned short delay;
+ void *data[10];
+};
+
+struct msm_sensor_power_setting_array {
+ struct msm_sensor_power_setting power_setting_a[MAX_POWER_CONFIG];
+ struct msm_sensor_power_setting *power_setting;
+ unsigned short size;
+ struct msm_sensor_power_setting power_down_setting_a[MAX_POWER_CONFIG];
+ struct msm_sensor_power_setting *power_down_setting;
+ unsigned short size_down;
+};
+
+enum msm_camera_i2c_operation {
+ MSM_CAM_WRITE = 0,
+ MSM_CAM_POLL,
+ MSM_CAM_READ,
+};
+
+struct msm_sensor_i2c_sync_params {
+ unsigned int cid;
+ int csid;
+ unsigned short line;
+ unsigned short delay;
+};
+
+struct msm_camera_reg_settings_t {
+ uint16_t reg_addr;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ uint16_t reg_data;
+ enum msm_camera_i2c_data_type data_type;
+ enum msm_camera_i2c_operation i2c_operation;
+ uint16_t delay;
+};
+
+struct msm_eeprom_mem_map_t {
+ int slave_addr;
+ struct msm_camera_reg_settings_t
+ mem_settings[MSM_EEPROM_MEMORY_MAP_MAX_SIZE];
+ int memory_map_size;
+};
+
+struct msm_eeprom_memory_map_array {
+ struct msm_eeprom_mem_map_t memory_map[MSM_EEPROM_MAX_MEM_MAP_CNT];
+ uint32_t msm_size_of_max_mappings;
+};
+
+struct msm_sensor_init_params {
+ /* mask of modes supported: 2D, 3D */
+ int modes_supported;
+ /* sensor position: front, back */
+ enum camb_position_t position;
+ /* sensor mount angle */
+ unsigned int sensor_mount_angle;
+};
+
+struct msm_sensor_id_info_t {
+ unsigned short sensor_id_reg_addr;
+ unsigned short sensor_id;
+ unsigned short sensor_id_mask;
+ // added in LeEco
+ unsigned char module_id;
+ unsigned char vcm_id;
+};
+
+struct msm_camera_sensor_slave_info {
+ char sensor_name[32];
+ char eeprom_name[32];
+ char actuator_name[32];
+ char ois_name[32];
+ char flash_name[32];
+ enum msm_sensor_camera_id_t camera_id;
+ unsigned short slave_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ struct msm_sensor_id_info_t sensor_id_info;
+ struct msm_sensor_power_setting_array power_setting_array;
+ unsigned char is_init_params_valid;
+ struct msm_sensor_init_params sensor_init_params;
+ enum msm_sensor_output_format_t output_format;
+};
+
+struct msm_camera_i2c_reg_array {
+ unsigned short reg_addr;
+ unsigned short reg_data;
+ unsigned int delay;
+};
+
+struct msm_camera_i2c_reg_setting {
+ struct msm_camera_i2c_reg_array *reg_setting;
+ unsigned short size;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ enum msm_camera_i2c_data_type data_type;
+ unsigned short delay;
+};
+
+struct msm_camera_csid_vc_cfg {
+ unsigned char cid;
+ unsigned char dt;
+ unsigned char decode_format;
+};
+
+struct msm_camera_csid_lut_params {
+ unsigned char num_cid;
+ struct msm_camera_csid_vc_cfg vc_cfg_a[MAX_CID];
+ struct msm_camera_csid_vc_cfg *vc_cfg[MAX_CID];
+};
+
+struct msm_camera_csid_params {
+ unsigned char lane_cnt;
+ unsigned short lane_assign;
+ unsigned char phy_sel;
+ unsigned int csi_clk;
+ struct msm_camera_csid_lut_params lut_params;
+ unsigned char csi_3p_sel;
+};
+
+struct msm_camera_csid_testmode_parms {
+ unsigned int num_bytes_per_line;
+ unsigned int num_lines;
+ unsigned int h_blanking_count;
+ unsigned int v_blanking_count;
+ unsigned int payload_mode;
+};
+
+struct msm_camera_csiphy_params {
+ unsigned char lane_cnt;
+ unsigned char settle_cnt;
+ unsigned short lane_mask;
+ unsigned char combo_mode;
+ unsigned char csid_core;
+ unsigned int csiphy_clk;
+ unsigned char csi_3phase;
+};
+
+struct msm_camera_i2c_seq_reg_array {
+ unsigned short reg_addr;
+ unsigned char reg_data[I2C_SEQ_REG_DATA_MAX];
+ unsigned short reg_data_size;
+};
+
+struct msm_camera_i2c_seq_reg_setting {
+ struct msm_camera_i2c_seq_reg_array *reg_setting;
+ unsigned short size;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ unsigned short delay;
+};
+
+struct msm_actuator_reg_params_t {
+ enum msm_actuator_write_type reg_write_type;
+ unsigned int hw_mask;
+ unsigned short reg_addr;
+ unsigned short hw_shift;
+ unsigned short data_shift;
+ unsigned short data_type;
+ unsigned short addr_type;
+ unsigned short reg_data;
+ unsigned short delay;
+};
+
+
+struct damping_params_t {
+ unsigned int damping_step;
+ unsigned int damping_delay;
+ unsigned int hw_params;
+};
+
+struct region_params_t {
+ /* [0] = ForwardDirection Macro boundary
+ [1] = ReverseDirection Inf boundary
+ */
+ unsigned short step_bound[2];
+ unsigned short code_per_step;
+ /* qvalue for converting float type numbers to integer format */
+ unsigned int qvalue;
+};
+
+struct reg_settings_t {
+ unsigned short reg_addr;
+ enum msm_actuator_addr_type addr_type;
+ unsigned short reg_data;
+ enum msm_actuator_data_type data_type;
+ enum msm_actuator_i2c_operation i2c_operation;
+ unsigned int delay;
+};
+
+struct msm_camera_i2c_reg_setting_array {
+ struct msm_camera_i2c_reg_array reg_setting_a[MAX_I2C_REG_SET];
+ unsigned short size;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ enum msm_camera_i2c_data_type data_type;
+ unsigned short delay;
+};
+#endif /* __LINUX_MSM_CAM_SENSOR_H */
diff --git a/selfdrive/visiond/include/msmb_camera.h b/selfdrive/visiond/include/msmb_camera.h
new file mode 100644
index 00000000000000..f4c4b3e183e86c
--- /dev/null
+++ b/selfdrive/visiond/include/msmb_camera.h
@@ -0,0 +1,220 @@
+#ifndef __LINUX_MSMB_CAMERA_H
+#define __LINUX_MSMB_CAMERA_H
+
+#include
+#include
+#include
+
+#define MSM_CAM_LOGSYNC_FILE_NAME "logsync"
+#define MSM_CAM_LOGSYNC_FILE_BASEDIR "camera"
+
+#define MSM_CAM_V4L2_IOCTL_NOTIFY \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 30, struct msm_v4l2_event_data)
+
+#define MSM_CAM_V4L2_IOCTL_NOTIFY_META \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 31, struct msm_v4l2_event_data)
+
+#define MSM_CAM_V4L2_IOCTL_CMD_ACK \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 32, struct msm_v4l2_event_data)
+
+#define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 33, struct msm_v4l2_event_data)
+
+#define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 34, struct msm_v4l2_event_data)
+
+#ifdef CONFIG_COMPAT
+#define MSM_CAM_V4L2_IOCTL_NOTIFY32 \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 30, struct v4l2_event32)
+
+#define MSM_CAM_V4L2_IOCTL_NOTIFY_META32 \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 31, struct v4l2_event32)
+
+#define MSM_CAM_V4L2_IOCTL_CMD_ACK32 \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 32, struct v4l2_event32)
+
+#define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR32 \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 33, struct v4l2_event32)
+
+#define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG32 \
+ _IOW('V', BASE_VIDIOC_PRIVATE + 34, struct v4l2_event32)
+
+#endif
+
+#define QCAMERA_DEVICE_GROUP_ID 1
+#define QCAMERA_VNODE_GROUP_ID 2
+#define MSM_CAMERA_NAME "msm_camera"
+#define MSM_CONFIGURATION_NAME "msm_config"
+
+#define MSM_CAMERA_SUBDEV_CSIPHY 0
+#define MSM_CAMERA_SUBDEV_CSID 1
+#define MSM_CAMERA_SUBDEV_ISPIF 2
+#define MSM_CAMERA_SUBDEV_VFE 3
+#define MSM_CAMERA_SUBDEV_AXI 4
+#define MSM_CAMERA_SUBDEV_VPE 5
+#define MSM_CAMERA_SUBDEV_SENSOR 6
+#define MSM_CAMERA_SUBDEV_ACTUATOR 7
+#define MSM_CAMERA_SUBDEV_EEPROM 8
+#define MSM_CAMERA_SUBDEV_CPP 9
+#define MSM_CAMERA_SUBDEV_CCI 10
+#define MSM_CAMERA_SUBDEV_LED_FLASH 11
+#define MSM_CAMERA_SUBDEV_STROBE_FLASH 12
+#define MSM_CAMERA_SUBDEV_BUF_MNGR 13
+#define MSM_CAMERA_SUBDEV_SENSOR_INIT 14
+#define MSM_CAMERA_SUBDEV_OIS 15
+#define MSM_CAMERA_SUBDEV_FLASH 16
+#define MSM_CAMERA_SUBDEV_EXT 17
+
+#define MSM_MAX_CAMERA_SENSORS 5
+
+/* The below macro is defined to put an upper limit on maximum
+ * number of buffer requested per stream. In case of extremely
+ * large value for number of buffer due to data structure corruption
+ * we return error to avoid integer overflow. Group processing
+ * can have max of 9 groups of 8 bufs each. This value may be
+ * configured in future*/
+#define MSM_CAMERA_MAX_STREAM_BUF 72
+
+/* Max batch size of processing */
+#define MSM_CAMERA_MAX_USER_BUFF_CNT 16
+
+/* featur base */
+#define MSM_CAMERA_FEATURE_BASE 0x00010000
+#define MSM_CAMERA_FEATURE_SHUTDOWN (MSM_CAMERA_FEATURE_BASE + 1)
+
+#define MSM_CAMERA_STATUS_BASE 0x00020000
+#define MSM_CAMERA_STATUS_FAIL (MSM_CAMERA_STATUS_BASE + 1)
+#define MSM_CAMERA_STATUS_SUCCESS (MSM_CAMERA_STATUS_BASE + 2)
+
+/* event type */
+#define MSM_CAMERA_V4L2_EVENT_TYPE (V4L2_EVENT_PRIVATE_START + 0x00002000)
+
+/* event id */
+#define MSM_CAMERA_EVENT_MIN 0
+#define MSM_CAMERA_NEW_SESSION (MSM_CAMERA_EVENT_MIN + 1)
+#define MSM_CAMERA_DEL_SESSION (MSM_CAMERA_EVENT_MIN + 2)
+#define MSM_CAMERA_SET_PARM (MSM_CAMERA_EVENT_MIN + 3)
+#define MSM_CAMERA_GET_PARM (MSM_CAMERA_EVENT_MIN + 4)
+#define MSM_CAMERA_MAPPING_CFG (MSM_CAMERA_EVENT_MIN + 5)
+#define MSM_CAMERA_MAPPING_SES (MSM_CAMERA_EVENT_MIN + 6)
+#define MSM_CAMERA_MSM_NOTIFY (MSM_CAMERA_EVENT_MIN + 7)
+#define MSM_CAMERA_EVENT_MAX (MSM_CAMERA_EVENT_MIN + 8)
+
+/* data.command */
+#define MSM_CAMERA_PRIV_S_CROP (V4L2_CID_PRIVATE_BASE + 1)
+#define MSM_CAMERA_PRIV_G_CROP (V4L2_CID_PRIVATE_BASE + 2)
+#define MSM_CAMERA_PRIV_G_FMT (V4L2_CID_PRIVATE_BASE + 3)
+#define MSM_CAMERA_PRIV_S_FMT (V4L2_CID_PRIVATE_BASE + 4)
+#define MSM_CAMERA_PRIV_TRY_FMT (V4L2_CID_PRIVATE_BASE + 5)
+#define MSM_CAMERA_PRIV_METADATA (V4L2_CID_PRIVATE_BASE + 6)
+#define MSM_CAMERA_PRIV_QUERY_CAP (V4L2_CID_PRIVATE_BASE + 7)
+#define MSM_CAMERA_PRIV_STREAM_ON (V4L2_CID_PRIVATE_BASE + 8)
+#define MSM_CAMERA_PRIV_STREAM_OFF (V4L2_CID_PRIVATE_BASE + 9)
+#define MSM_CAMERA_PRIV_NEW_STREAM (V4L2_CID_PRIVATE_BASE + 10)
+#define MSM_CAMERA_PRIV_DEL_STREAM (V4L2_CID_PRIVATE_BASE + 11)
+#define MSM_CAMERA_PRIV_SHUTDOWN (V4L2_CID_PRIVATE_BASE + 12)
+#define MSM_CAMERA_PRIV_STREAM_INFO_SYNC \
+ (V4L2_CID_PRIVATE_BASE + 13)
+#define MSM_CAMERA_PRIV_G_SESSION_ID (V4L2_CID_PRIVATE_BASE + 14)
+#define MSM_CAMERA_PRIV_CMD_MAX 20
+
+/* data.status - success */
+#define MSM_CAMERA_CMD_SUCESS 0x00000001
+#define MSM_CAMERA_BUF_MAP_SUCESS 0x00000002
+
+/* data.status - error */
+#define MSM_CAMERA_ERR_EVT_BASE 0x00010000
+#define MSM_CAMERA_ERR_CMD_FAIL (MSM_CAMERA_ERR_EVT_BASE + 1)
+#define MSM_CAMERA_ERR_MAPPING (MSM_CAMERA_ERR_EVT_BASE + 2)
+#define MSM_CAMERA_ERR_DEVICE_BUSY (MSM_CAMERA_ERR_EVT_BASE + 3)
+
+/* The msm_v4l2_event_data structure should match the
+ * v4l2_event.u.data field.
+ * should not exceed 16 elements */
+struct msm_v4l2_event_data {
+ /*word 0*/
+ unsigned int command;
+ /*word 1*/
+ unsigned int status;
+ /*word 2*/
+ unsigned int session_id;
+ /*word 3*/
+ unsigned int stream_id;
+ /*word 4*/
+ unsigned int map_op;
+ /*word 5*/
+ unsigned int map_buf_idx;
+ /*word 6*/
+ unsigned int notify;
+ /*word 7*/
+ unsigned int arg_value;
+ /*word 8*/
+ unsigned int ret_value;
+ /*word 9*/
+ unsigned int v4l2_event_type;
+ /*word 10*/
+ unsigned int v4l2_event_id;
+ /*word 11*/
+ unsigned int handle;
+ /*word 12*/
+ unsigned int nop6;
+ /*word 13*/
+ unsigned int nop7;
+ /*word 14*/
+ unsigned int nop8;
+ /*word 15*/
+ unsigned int nop9;
+};
+
+/* map to v4l2_format.fmt.raw_data */
+struct msm_v4l2_format_data {
+ enum v4l2_buf_type type;
+ unsigned int width;
+ unsigned int height;
+ unsigned int pixelformat; /* FOURCC */
+ unsigned char num_planes;
+ unsigned int plane_sizes[VIDEO_MAX_PLANES];
+};
+
+/* MSM Four-character-code (FOURCC) */
+#define msm_v4l2_fourcc(a, b, c, d)\
+ ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) |\
+ ((__u32)(d) << 24))
+
+/* Composite stats */
+#define MSM_V4L2_PIX_FMT_STATS_COMB v4l2_fourcc('S', 'T', 'C', 'M')
+/* AEC stats */
+#define MSM_V4L2_PIX_FMT_STATS_AE v4l2_fourcc('S', 'T', 'A', 'E')
+/* AF stats */
+#define MSM_V4L2_PIX_FMT_STATS_AF v4l2_fourcc('S', 'T', 'A', 'F')
+/* AWB stats */
+#define MSM_V4L2_PIX_FMT_STATS_AWB v4l2_fourcc('S', 'T', 'W', 'B')
+/* IHIST stats */
+#define MSM_V4L2_PIX_FMT_STATS_IHST v4l2_fourcc('I', 'H', 'S', 'T')
+/* Column count stats */
+#define MSM_V4L2_PIX_FMT_STATS_CS v4l2_fourcc('S', 'T', 'C', 'S')
+/* Row count stats */
+#define MSM_V4L2_PIX_FMT_STATS_RS v4l2_fourcc('S', 'T', 'R', 'S')
+/* Bayer Grid stats */
+#define MSM_V4L2_PIX_FMT_STATS_BG v4l2_fourcc('S', 'T', 'B', 'G')
+/* Bayer focus stats */
+#define MSM_V4L2_PIX_FMT_STATS_BF v4l2_fourcc('S', 'T', 'B', 'F')
+/* Bayer hist stats */
+#define MSM_V4L2_PIX_FMT_STATS_BHST v4l2_fourcc('B', 'H', 'S', 'T')
+
+enum smmu_attach_mode {
+ NON_SECURE_MODE = 0x01,
+ SECURE_MODE = 0x02,
+ MAX_PROTECTION_MODE = 0x03,
+};
+
+struct msm_camera_smmu_attach_type {
+ enum smmu_attach_mode attach;
+};
+
+struct msm_camera_user_buf_cont_t {
+ unsigned int buf_cnt;
+ unsigned int buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT];
+};
+
+#endif /* __LINUX_MSMB_CAMERA_H */
diff --git a/selfdrive/visiond/include/msmb_isp.h b/selfdrive/visiond/include/msmb_isp.h
new file mode 100644
index 00000000000000..35589e050a4d06
--- /dev/null
+++ b/selfdrive/visiond/include/msmb_isp.h
@@ -0,0 +1,880 @@
+#ifndef __MSMB_ISP__
+#define __MSMB_ISP__
+
+#include
+
+#define MAX_PLANES_PER_STREAM 3
+#define MAX_NUM_STREAM 7
+
+#define ISP_VERSION_47 47
+#define ISP_VERSION_46 46
+#define ISP_VERSION_44 44
+#define ISP_VERSION_40 40
+#define ISP_VERSION_32 32
+#define ISP_NATIVE_BUF_BIT (0x10000 << 0)
+#define ISP0_BIT (0x10000 << 1)
+#define ISP1_BIT (0x10000 << 2)
+#define ISP_META_CHANNEL_BIT (0x10000 << 3)
+#define ISP_SCRATCH_BUF_BIT (0x10000 << 4)
+#define ISP_OFFLINE_STATS_BIT (0x10000 << 5)
+#define ISP_STATS_STREAM_BIT 0x80000000
+
+struct msm_vfe_cfg_cmd_list;
+
+enum ISP_START_PIXEL_PATTERN {
+ ISP_BAYER_RGRGRG,
+ ISP_BAYER_GRGRGR,
+ ISP_BAYER_BGBGBG,
+ ISP_BAYER_GBGBGB,
+ ISP_YUV_YCbYCr,
+ ISP_YUV_YCrYCb,
+ ISP_YUV_CbYCrY,
+ ISP_YUV_CrYCbY,
+ ISP_PIX_PATTERN_MAX
+};
+
+enum msm_vfe_plane_fmt {
+ Y_PLANE,
+ CB_PLANE,
+ CR_PLANE,
+ CRCB_PLANE,
+ CBCR_PLANE,
+ VFE_PLANE_FMT_MAX
+};
+
+enum msm_vfe_input_src {
+ VFE_PIX_0,
+ VFE_RAW_0,
+ VFE_RAW_1,
+ VFE_RAW_2,
+ VFE_SRC_MAX,
+};
+
+enum msm_vfe_axi_stream_src {
+ PIX_ENCODER,
+ PIX_VIEWFINDER,
+ PIX_VIDEO,
+ CAMIF_RAW,
+ IDEAL_RAW,
+ RDI_INTF_0,
+ RDI_INTF_1,
+ RDI_INTF_2,
+ VFE_AXI_SRC_MAX
+};
+
+enum msm_vfe_frame_skip_pattern {
+ NO_SKIP,
+ EVERY_2FRAME,
+ EVERY_3FRAME,
+ EVERY_4FRAME,
+ EVERY_5FRAME,
+ EVERY_6FRAME,
+ EVERY_7FRAME,
+ EVERY_8FRAME,
+ EVERY_16FRAME,
+ EVERY_32FRAME,
+ SKIP_ALL,
+ SKIP_RANGE,
+ MAX_SKIP,
+};
+
+/*
+ * Define an unused period. When this period is set it means that the stream is
+ * stopped(i.e the pattern is 0). We don't track the current pattern, just the
+ * period defines what the pattern is, if period is this then pattern is 0 else
+ * pattern is 1
+ */
+#define MSM_VFE_STREAM_STOP_PERIOD 15
+
+enum msm_isp_stats_type {
+ MSM_ISP_STATS_AEC, /* legacy based AEC */
+ MSM_ISP_STATS_AF, /* legacy based AF */
+ MSM_ISP_STATS_AWB, /* legacy based AWB */
+ MSM_ISP_STATS_RS, /* legacy based RS */
+ MSM_ISP_STATS_CS, /* legacy based CS */
+ MSM_ISP_STATS_IHIST, /* legacy based HIST */
+ MSM_ISP_STATS_SKIN, /* legacy based SKIN */
+ MSM_ISP_STATS_BG, /* Bayer Grids */
+ MSM_ISP_STATS_BF, /* Bayer Focus */
+ MSM_ISP_STATS_BE, /* Bayer Exposure*/
+ MSM_ISP_STATS_BHIST, /* Bayer Hist */
+ MSM_ISP_STATS_BF_SCALE, /* Bayer Focus scale */
+ MSM_ISP_STATS_HDR_BE, /* HDR Bayer Exposure */
+ MSM_ISP_STATS_HDR_BHIST, /* HDR Bayer Hist */
+ MSM_ISP_STATS_AEC_BG, /* AEC BG */
+ MSM_ISP_STATS_MAX /* MAX */
+};
+
+/*
+ * @stats_type_mask: Stats type mask (enum msm_isp_stats_type).
+ * @stream_src_mask: Stream src mask (enum msm_vfe_axi_stream_src)
+ * @skip_mode: skip pattern, if skip mode is range only then min/max is used
+ * @min_frame_id: minimum frame id (valid only if skip_mode = RANGE)
+ * @max_frame_id: maximum frame id (valid only if skip_mode = RANGE)
+*/
+struct msm_isp_sw_framskip {
+ uint32_t stats_type_mask;
+ uint32_t stream_src_mask;
+ enum msm_vfe_frame_skip_pattern skip_mode;
+ uint32_t min_frame_id;
+ uint32_t max_frame_id;
+};
+
+enum msm_vfe_testgen_color_pattern {
+ COLOR_BAR_8_COLOR,
+ UNICOLOR_WHITE,
+ UNICOLOR_YELLOW,
+ UNICOLOR_CYAN,
+ UNICOLOR_GREEN,
+ UNICOLOR_MAGENTA,
+ UNICOLOR_RED,
+ UNICOLOR_BLUE,
+ UNICOLOR_BLACK,
+ MAX_COLOR,
+};
+
+enum msm_vfe_camif_input {
+ CAMIF_DISABLED,
+ CAMIF_PAD_REG_INPUT,
+ CAMIF_MIDDI_INPUT,
+ CAMIF_MIPI_INPUT,
+};
+
+struct msm_vfe_fetch_engine_cfg {
+ uint32_t input_format;
+ uint32_t buf_width;
+ uint32_t buf_height;
+ uint32_t fetch_width;
+ uint32_t fetch_height;
+ uint32_t x_offset;
+ uint32_t y_offset;
+ uint32_t buf_stride;
+};
+
+enum msm_vfe_camif_output_format {
+ CAMIF_QCOM_RAW,
+ CAMIF_MIPI_RAW,
+ CAMIF_PLAIN_8,
+ CAMIF_PLAIN_16,
+ CAMIF_MAX_FORMAT,
+};
+
+/*
+ * Camif output general configuration
+ */
+struct msm_vfe_camif_subsample_cfg {
+ uint32_t irq_subsample_period;
+ uint32_t irq_subsample_pattern;
+ uint32_t sof_counter_step;
+ uint32_t pixel_skip;
+ uint32_t line_skip;
+ uint32_t first_line;
+ uint32_t last_line;
+ uint32_t first_pixel;
+ uint32_t last_pixel;
+ enum msm_vfe_camif_output_format output_format;
+};
+
+/*
+ * Camif frame and window configuration
+ */
+struct msm_vfe_camif_cfg {
+ uint32_t lines_per_frame;
+ uint32_t pixels_per_line;
+ uint32_t first_pixel;
+ uint32_t last_pixel;
+ uint32_t first_line;
+ uint32_t last_line;
+ uint32_t epoch_line0;
+ uint32_t epoch_line1;
+ uint32_t is_split;
+ enum msm_vfe_camif_input camif_input;
+ struct msm_vfe_camif_subsample_cfg subsample_cfg;
+};
+
+struct msm_vfe_testgen_cfg {
+ uint32_t lines_per_frame;
+ uint32_t pixels_per_line;
+ uint32_t v_blank;
+ uint32_t h_blank;
+ enum ISP_START_PIXEL_PATTERN pixel_bayer_pattern;
+ uint32_t rotate_period;
+ enum msm_vfe_testgen_color_pattern color_bar_pattern;
+ uint32_t burst_num_frame;
+};
+
+enum msm_vfe_inputmux {
+ CAMIF,
+ TESTGEN,
+ EXTERNAL_READ,
+};
+
+enum msm_vfe_stats_composite_group {
+ STATS_COMPOSITE_GRP_NONE,
+ STATS_COMPOSITE_GRP_1,
+ STATS_COMPOSITE_GRP_2,
+ STATS_COMPOSITE_GRP_MAX,
+};
+
+enum msm_vfe_hvx_streaming_cmd {
+ HVX_DISABLE,
+ HVX_ONE_WAY,
+ HVX_ROUND_TRIP
+};
+
+struct msm_vfe_pix_cfg {
+ struct msm_vfe_camif_cfg camif_cfg;
+ struct msm_vfe_testgen_cfg testgen_cfg;
+ struct msm_vfe_fetch_engine_cfg fetch_engine_cfg;
+ enum msm_vfe_inputmux input_mux;
+ enum ISP_START_PIXEL_PATTERN pixel_pattern;
+ uint32_t input_format;
+ enum msm_vfe_hvx_streaming_cmd hvx_cmd;
+ uint32_t is_split;
+};
+
+struct msm_vfe_rdi_cfg {
+ uint8_t cid;
+ uint8_t frame_based;
+};
+
+struct msm_vfe_input_cfg {
+ union {
+ struct msm_vfe_pix_cfg pix_cfg;
+ struct msm_vfe_rdi_cfg rdi_cfg;
+ } d;
+ enum msm_vfe_input_src input_src;
+ uint32_t input_pix_clk;
+};
+
+struct msm_vfe_fetch_eng_start {
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint32_t buf_idx;
+ uint8_t offline_mode;
+ uint32_t fd;
+ uint32_t buf_addr;
+ uint32_t frame_id;
+};
+
+struct msm_vfe_axi_plane_cfg {
+ uint32_t output_width; /*Include padding*/
+ uint32_t output_height;
+ uint32_t output_stride;
+ uint32_t output_scan_lines;
+ uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/
+ uint32_t plane_addr_offset;
+ uint8_t csid_src; /*RDI 0-2*/
+ uint8_t rdi_cid;/*CID 1-16*/
+};
+
+enum msm_stream_memory_input_t {
+ MEMORY_INPUT_DISABLED,
+ MEMORY_INPUT_ENABLED
+};
+
+struct msm_vfe_axi_stream_request_cmd {
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint32_t vt_enable;
+ uint32_t output_format;/*Planar/RAW/Misc*/
+ enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
+ struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
+
+ uint32_t burst_count;
+ uint32_t hfr_mode;
+ uint8_t frame_base;
+
+ uint32_t init_frame_drop; /*MAX 31 Frames*/
+ enum msm_vfe_frame_skip_pattern frame_skip_pattern;
+ uint8_t buf_divert; /* if TRUE no vb2 buf done. */
+ /*Return values*/
+ uint32_t axi_stream_handle;
+ uint32_t controllable_output;
+ uint32_t burst_len;
+ /* Flag indicating memory input stream */
+ enum msm_stream_memory_input_t memory_input;
+};
+
+struct msm_vfe_axi_stream_release_cmd {
+ uint32_t stream_handle;
+};
+
+enum msm_vfe_axi_stream_cmd {
+ STOP_STREAM,
+ START_STREAM,
+ STOP_IMMEDIATELY,
+};
+
+struct msm_vfe_axi_stream_cfg_cmd {
+ uint8_t num_streams;
+ uint32_t stream_handle[VFE_AXI_SRC_MAX];
+ enum msm_vfe_axi_stream_cmd cmd;
+ uint8_t sync_frame_id_src;
+};
+
+enum msm_vfe_axi_stream_update_type {
+ ENABLE_STREAM_BUF_DIVERT,
+ DISABLE_STREAM_BUF_DIVERT,
+ UPDATE_STREAM_FRAMEDROP_PATTERN,
+ UPDATE_STREAM_STATS_FRAMEDROP_PATTERN,
+ UPDATE_STREAM_AXI_CONFIG,
+ UPDATE_STREAM_REQUEST_FRAMES,
+ UPDATE_STREAM_ADD_BUFQ,
+ UPDATE_STREAM_REMOVE_BUFQ,
+ UPDATE_STREAM_SW_FRAME_DROP,
+};
+
+enum msm_vfe_iommu_type {
+ IOMMU_ATTACH,
+ IOMMU_DETACH,
+};
+
+enum msm_vfe_buff_queue_id {
+ VFE_BUF_QUEUE_DEFAULT,
+ VFE_BUF_QUEUE_SHARED,
+ VFE_BUF_QUEUE_MAX,
+};
+
+struct msm_vfe_axi_stream_cfg_update_info {
+ uint32_t stream_handle;
+ uint32_t output_format;
+ uint32_t user_stream_id;
+ uint32_t frame_id;
+ enum msm_vfe_frame_skip_pattern skip_pattern;
+ struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
+ struct msm_isp_sw_framskip sw_skip_info;
+};
+
+struct msm_vfe_axi_halt_cmd {
+ uint32_t stop_camif;
+ uint32_t overflow_detected;
+ uint32_t blocking_halt;
+};
+
+struct msm_vfe_axi_reset_cmd {
+ uint32_t blocking;
+ uint32_t frame_id;
+};
+
+struct msm_vfe_axi_restart_cmd {
+ uint32_t enable_camif;
+};
+
+struct msm_vfe_axi_stream_update_cmd {
+ uint32_t num_streams;
+ enum msm_vfe_axi_stream_update_type update_type;
+ struct msm_vfe_axi_stream_cfg_update_info
+ update_info[MSM_ISP_STATS_MAX];
+};
+
+struct msm_vfe_smmu_attach_cmd {
+ uint32_t security_mode;
+ uint32_t iommu_attach_mode;
+};
+
+struct msm_vfe_stats_stream_request_cmd {
+ uint32_t session_id;
+ uint32_t stream_id;
+ enum msm_isp_stats_type stats_type;
+ uint32_t composite_flag;
+ uint32_t framedrop_pattern;
+ uint32_t init_frame_drop; /*MAX 31 Frames*/
+ uint32_t irq_subsample_pattern;
+ uint32_t buffer_offset;
+ uint32_t stream_handle;
+};
+
+struct msm_vfe_stats_stream_release_cmd {
+ uint32_t stream_handle;
+};
+struct msm_vfe_stats_stream_cfg_cmd {
+ uint8_t num_streams;
+ uint32_t stream_handle[MSM_ISP_STATS_MAX];
+ uint8_t enable;
+ uint32_t stats_burst_len;
+};
+
+enum msm_vfe_reg_cfg_type {
+ VFE_WRITE,
+ VFE_WRITE_MB,
+ VFE_READ,
+ VFE_CFG_MASK,
+ VFE_WRITE_DMI_16BIT,
+ VFE_WRITE_DMI_32BIT,
+ VFE_WRITE_DMI_64BIT,
+ VFE_READ_DMI_16BIT,
+ VFE_READ_DMI_32BIT,
+ VFE_READ_DMI_64BIT,
+ GET_MAX_CLK_RATE,
+ GET_CLK_RATES,
+ GET_ISP_ID,
+ VFE_HW_UPDATE_LOCK,
+ VFE_HW_UPDATE_UNLOCK,
+ SET_WM_UB_SIZE,
+ SET_UB_POLICY,
+};
+
+struct msm_vfe_cfg_cmd2 {
+ uint16_t num_cfg;
+ uint16_t cmd_len;
+ void __user *cfg_data;
+ void __user *cfg_cmd;
+};
+
+struct msm_vfe_cfg_cmd_list {
+ struct msm_vfe_cfg_cmd2 cfg_cmd;
+ struct msm_vfe_cfg_cmd_list *next;
+ uint32_t next_size;
+};
+
+struct msm_vfe_reg_rw_info {
+ uint32_t reg_offset;
+ uint32_t cmd_data_offset;
+ uint32_t len;
+};
+
+struct msm_vfe_reg_mask_info {
+ uint32_t reg_offset;
+ uint32_t mask;
+ uint32_t val;
+};
+
+struct msm_vfe_reg_dmi_info {
+ uint32_t hi_tbl_offset; /*Optional*/
+ uint32_t lo_tbl_offset; /*Required*/
+ uint32_t len;
+};
+
+struct msm_vfe_reg_cfg_cmd {
+ union {
+ struct msm_vfe_reg_rw_info rw_info;
+ struct msm_vfe_reg_mask_info mask_info;
+ struct msm_vfe_reg_dmi_info dmi_info;
+ } u;
+
+ enum msm_vfe_reg_cfg_type cmd_type;
+};
+
+enum vfe_sd_type {
+ VFE_SD_0 = 0,
+ VFE_SD_1,
+ VFE_SD_COMMON,
+ VFE_SD_MAX,
+};
+
+/* When you change the value below, check for the sof event_data size.
+ * V4l2 limits payload to 64 bytes */
+#define MS_NUM_SLAVE_MAX 1
+
+/* Usecases when 2 HW need to be related or synced */
+enum msm_vfe_dual_hw_type {
+ DUAL_NONE = 0,
+ DUAL_HW_VFE_SPLIT = 1,
+ DUAL_HW_MASTER_SLAVE = 2,
+};
+
+/* Type for 2 INTF when used in Master-Slave mode */
+enum msm_vfe_dual_hw_ms_type {
+ MS_TYPE_NONE,
+ MS_TYPE_MASTER,
+ MS_TYPE_SLAVE,
+};
+
+struct msm_isp_set_dual_hw_ms_cmd {
+ uint8_t num_src;
+ /* Each session can be only one type but multiple intf if YUV cam */
+ enum msm_vfe_dual_hw_ms_type dual_hw_ms_type;
+ /* Primary intf is mostly associated with preview.
+ * This primary intf SOF frame_id and timestamp is tracked
+ * and used to calculate delta */
+ enum msm_vfe_input_src primary_intf;
+ /* input_src array indicates other input INTF that may be Master/Slave.
+ * For these additional intf, frame_id and timestamp are not saved.
+ * However, if these are slaves then they will still get their
+ * frame_id from Master */
+ enum msm_vfe_input_src input_src[VFE_SRC_MAX];
+ uint32_t sof_delta_threshold; /* In milliseconds. Sent for Master */
+};
+
+enum msm_isp_buf_type {
+ ISP_PRIVATE_BUF,
+ ISP_SHARE_BUF,
+ MAX_ISP_BUF_TYPE,
+};
+
+struct msm_isp_unmap_buf_req {
+ uint32_t fd;
+};
+
+struct msm_isp_buf_request {
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint8_t num_buf;
+ uint32_t handle;
+ enum msm_isp_buf_type buf_type;
+};
+
+struct msm_isp_qbuf_plane {
+ uint32_t addr;
+ uint32_t offset;
+ uint32_t length;
+};
+
+struct msm_isp_qbuf_buffer {
+ struct msm_isp_qbuf_plane planes[MAX_PLANES_PER_STREAM];
+ uint32_t num_planes;
+};
+
+struct msm_isp_qbuf_info {
+ uint32_t handle;
+ int32_t buf_idx;
+ /*Only used for prepare buffer*/
+ struct msm_isp_qbuf_buffer buffer;
+ /*Only used for diverted buffer*/
+ uint32_t dirty_buf;
+};
+
+struct msm_isp_clk_rates {
+ uint32_t svs_rate;
+ uint32_t nominal_rate;
+ uint32_t high_rate;
+};
+
+struct msm_vfe_axi_src_state {
+ enum msm_vfe_input_src input_src;
+ uint32_t src_active;
+ uint32_t src_frame_id;
+};
+
+enum msm_isp_event_mask_index {
+ ISP_EVENT_MASK_INDEX_STATS_NOTIFY = 0,
+ ISP_EVENT_MASK_INDEX_ERROR = 1,
+ ISP_EVENT_MASK_INDEX_IOMMU_P_FAULT = 2,
+ ISP_EVENT_MASK_INDEX_STREAM_UPDATE_DONE = 3,
+ ISP_EVENT_MASK_INDEX_REG_UPDATE = 4,
+ ISP_EVENT_MASK_INDEX_SOF = 5,
+ ISP_EVENT_MASK_INDEX_BUF_DIVERT = 6,
+ ISP_EVENT_MASK_INDEX_COMP_STATS_NOTIFY = 7,
+ ISP_EVENT_MASK_INDEX_MASK_FE_READ_DONE = 8,
+ ISP_EVENT_MASK_INDEX_BUF_DONE = 9,
+ ISP_EVENT_MASK_INDEX_REG_UPDATE_MISSING = 10,
+ ISP_EVENT_MASK_INDEX_PING_PONG_MISMATCH = 11,
+ ISP_EVENT_MASK_INDEX_BUF_FATAL_ERROR = 12,
+};
+
+
+#define ISP_EVENT_SUBS_MASK_NONE 0
+
+#define ISP_EVENT_SUBS_MASK_STATS_NOTIFY \
+ (1 << ISP_EVENT_MASK_INDEX_STATS_NOTIFY)
+
+#define ISP_EVENT_SUBS_MASK_ERROR \
+ (1 << ISP_EVENT_MASK_INDEX_ERROR)
+
+#define ISP_EVENT_SUBS_MASK_IOMMU_P_FAULT \
+ (1 << ISP_EVENT_MASK_INDEX_IOMMU_P_FAULT)
+
+#define ISP_EVENT_SUBS_MASK_STREAM_UPDATE_DONE \
+ (1 << ISP_EVENT_MASK_INDEX_STREAM_UPDATE_DONE)
+
+#define ISP_EVENT_SUBS_MASK_REG_UPDATE \
+ (1 << ISP_EVENT_MASK_INDEX_REG_UPDATE)
+
+#define ISP_EVENT_SUBS_MASK_SOF \
+ (1 << ISP_EVENT_MASK_INDEX_SOF)
+
+#define ISP_EVENT_SUBS_MASK_BUF_DIVERT \
+ (1 << ISP_EVENT_MASK_INDEX_BUF_DIVERT)
+
+#define ISP_EVENT_SUBS_MASK_COMP_STATS_NOTIFY \
+ (1 << ISP_EVENT_MASK_INDEX_COMP_STATS_NOTIFY)
+
+#define ISP_EVENT_SUBS_MASK_FE_READ_DONE \
+ (1 << ISP_EVENT_MASK_INDEX_MASK_FE_READ_DONE)
+
+#define ISP_EVENT_SUBS_MASK_BUF_DONE \
+ (1 << ISP_EVENT_MASK_INDEX_BUF_DONE)
+
+#define ISP_EVENT_SUBS_MASK_REG_UPDATE_MISSING \
+ (1 << ISP_EVENT_MASK_INDEX_REG_UPDATE_MISSING)
+
+#define ISP_EVENT_SUBS_MASK_PING_PONG_MISMATCH \
+ (1 << ISP_EVENT_MASK_INDEX_PING_PONG_MISMATCH)
+
+#define ISP_EVENT_SUBS_MASK_BUF_FATAL_ERROR \
+ (1 << ISP_EVENT_MASK_INDEX_BUF_FATAL_ERROR)
+
+enum msm_isp_event_idx {
+ ISP_REG_UPDATE = 0,
+ ISP_EPOCH_0 = 1,
+ ISP_EPOCH_1 = 2,
+ ISP_START_ACK = 3,
+ ISP_STOP_ACK = 4,
+ ISP_IRQ_VIOLATION = 5,
+ ISP_STATS_OVERFLOW = 6,
+ ISP_BUF_DONE = 7,
+ ISP_FE_RD_DONE = 8,
+ ISP_IOMMU_P_FAULT = 9,
+ ISP_ERROR = 10,
+ ISP_HW_FATAL_ERROR = 11,
+ ISP_PING_PONG_MISMATCH = 12,
+ ISP_REG_UPDATE_MISSING = 13,
+ ISP_BUF_FATAL_ERROR = 14,
+ ISP_EVENT_MAX = 15
+};
+
+#define ISP_EVENT_OFFSET 8
+#define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
+#define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
+#define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
+#define ISP_CAMIF_EVENT_BASE (ISP_EVENT_BASE + (3 << ISP_EVENT_OFFSET))
+#define ISP_STREAM_EVENT_BASE (ISP_EVENT_BASE + (4 << ISP_EVENT_OFFSET))
+#define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
+#define ISP_EVENT_EPOCH_0 (ISP_EVENT_BASE + ISP_EPOCH_0)
+#define ISP_EVENT_EPOCH_1 (ISP_EVENT_BASE + ISP_EPOCH_1)
+#define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
+#define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
+#define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
+#define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
+#define ISP_EVENT_ERROR (ISP_EVENT_BASE + ISP_ERROR)
+#define ISP_EVENT_SOF (ISP_CAMIF_EVENT_BASE)
+#define ISP_EVENT_EOF (ISP_CAMIF_EVENT_BASE + 1)
+#define ISP_EVENT_BUF_DONE (ISP_EVENT_BASE + ISP_BUF_DONE)
+#define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
+#define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
+#define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX)
+#define ISP_EVENT_FE_READ_DONE (ISP_EVENT_BASE + ISP_FE_RD_DONE)
+#define ISP_EVENT_IOMMU_P_FAULT (ISP_EVENT_BASE + ISP_IOMMU_P_FAULT)
+#define ISP_EVENT_HW_FATAL_ERROR (ISP_EVENT_BASE + ISP_HW_FATAL_ERROR)
+#define ISP_EVENT_PING_PONG_MISMATCH (ISP_EVENT_BASE + ISP_PING_PONG_MISMATCH)
+#define ISP_EVENT_REG_UPDATE_MISSING (ISP_EVENT_BASE + ISP_REG_UPDATE_MISSING)
+#define ISP_EVENT_BUF_FATAL_ERROR (ISP_EVENT_BASE + ISP_BUF_FATAL_ERROR)
+#define ISP_EVENT_STREAM_UPDATE_DONE (ISP_STREAM_EVENT_BASE)
+
+/* The msm_v4l2_event_data structure should match the
+ * v4l2_event.u.data field.
+ * should not exceed 64 bytes */
+
+struct msm_isp_buf_event {
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint32_t handle;
+ uint32_t output_format;
+ int8_t buf_idx;
+};
+struct msm_isp_fetch_eng_event {
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint32_t handle;
+ uint32_t fd;
+ int8_t buf_idx;
+ int8_t offline_mode;
+};
+struct msm_isp_stats_event {
+ uint32_t stats_mask; /* 4 bytes */
+ uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
+};
+
+struct msm_isp_stream_ack {
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint32_t handle;
+};
+
+enum msm_vfe_error_type {
+ ISP_ERROR_NONE,
+ ISP_ERROR_CAMIF,
+ ISP_ERROR_BUS_OVERFLOW,
+ ISP_ERROR_RETURN_EMPTY_BUFFER,
+ ISP_ERROR_FRAME_ID_MISMATCH,
+ ISP_ERROR_MAX,
+};
+
+struct msm_isp_error_info {
+ enum msm_vfe_error_type err_type;
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint32_t stream_id_mask;
+};
+
+/* This structure reports delta between master and slave */
+struct msm_isp_ms_delta_info {
+ uint8_t num_delta_info;
+ uint32_t delta[MS_NUM_SLAVE_MAX];
+};
+
+/* This is sent in EPOCH irq */
+struct msm_isp_output_info {
+ uint8_t regs_not_updated;
+ /* mask with bufq_handle for regs not updated or return empty */
+ uint16_t output_err_mask;
+ /* mask with stream_idx for get_buf failed */
+ uint8_t stream_framedrop_mask;
+ /* mask with stats stream_idx for get_buf failed */
+ uint16_t stats_framedrop_mask;
+ /* delta between master and slave */
+};
+
+/* This structure is piggybacked with SOF event */
+struct msm_isp_sof_info {
+ uint8_t regs_not_updated;
+ /* mask with AXI_SRC for regs not updated */
+ uint16_t reg_update_fail_mask;
+ /* mask with bufq_handle for get_buf failed */
+ uint32_t stream_get_buf_fail_mask;
+ /* mask with stats stream_idx for get_buf failed */
+ uint16_t stats_get_buf_fail_mask;
+ /* delta between master and slave */
+ struct msm_isp_ms_delta_info ms_delta_info;
+};
+
+struct msm_isp_event_data {
+ /*Wall clock except for buffer divert events
+ *which use monotonic clock
+ */
+ struct timeval timestamp;
+ /* Monotonic timestamp since bootup */
+ struct timeval mono_timestamp;
+ uint32_t frame_id;
+ union {
+ /* Sent for Stats_Done event */
+ struct msm_isp_stats_event stats;
+ /* Sent for Buf_Divert event */
+ struct msm_isp_buf_event buf_done;
+ /* Sent for offline fetch done event */
+ struct msm_isp_fetch_eng_event fetch_done;
+ /* Sent for Error_Event */
+ struct msm_isp_error_info error_info;
+ /*
+ * This struct needs to be removed once
+ * userspace switches to sof_info
+ */
+ struct msm_isp_output_info output_info;
+ /* Sent for SOF event */
+ struct msm_isp_sof_info sof_info;
+ } u; /* union can have max 52 bytes */
+};
+
+#ifdef CONFIG_COMPAT
+struct msm_isp_event_data32 {
+ struct compat_timeval timestamp;
+ struct compat_timeval mono_timestamp;
+ uint32_t frame_id;
+ union {
+ struct msm_isp_stats_event stats;
+ struct msm_isp_buf_event buf_done;
+ struct msm_isp_fetch_eng_event fetch_done;
+ struct msm_isp_error_info error_info;
+ struct msm_isp_output_info output_info;
+ struct msm_isp_sof_info sof_info;
+ } u;
+};
+#endif
+
+#define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
+#define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
+#define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
+#define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
+#define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
+#define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
+#define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
+#define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
+#define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
+#define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
+#define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
+#define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
+#define V4L2_PIX_FMT_QBGGR14 v4l2_fourcc('Q', 'B', 'G', '4')
+#define V4L2_PIX_FMT_QGBRG14 v4l2_fourcc('Q', 'G', 'B', '4')
+#define V4L2_PIX_FMT_QGRBG14 v4l2_fourcc('Q', 'G', 'R', '4')
+#define V4L2_PIX_FMT_QRGGB14 v4l2_fourcc('Q', 'R', 'G', '4')
+#define V4L2_PIX_FMT_P16BGGR10 v4l2_fourcc('P', 'B', 'G', '0')
+#define V4L2_PIX_FMT_P16GBRG10 v4l2_fourcc('P', 'G', 'B', '0')
+#define V4L2_PIX_FMT_P16GRBG10 v4l2_fourcc('P', 'G', 'R', '0')
+#define V4L2_PIX_FMT_P16RGGB10 v4l2_fourcc('P', 'R', 'G', '0')
+#define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4')
+#define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1')
+#define V4L2_PIX_FMT_META v4l2_fourcc('Q', 'M', 'E', 'T')
+#define V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4') /* 14 BGBG.GRGR.*/
+#define V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4') /* 14 GBGB.RGRG.*/
+#define V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4') /* 14 GRGR.BGBG.*/
+#define V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4') /* 14 RGRG.GBGB.*/
+
+#define VIDIOC_MSM_VFE_REG_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2)
+
+#define VIDIOC_MSM_ISP_REQUEST_BUF \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request)
+
+#define VIDIOC_MSM_ISP_ENQUEUE_BUF \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info)
+
+#define VIDIOC_MSM_ISP_RELEASE_BUF \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request)
+
+#define VIDIOC_MSM_ISP_REQUEST_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd)
+
+#define VIDIOC_MSM_ISP_CFG_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd)
+
+#define VIDIOC_MSM_ISP_RELEASE_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd)
+
+#define VIDIOC_MSM_ISP_INPUT_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg)
+
+#define VIDIOC_MSM_ISP_SET_SRC_STATE \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state)
+
+#define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+9, \
+ struct msm_vfe_stats_stream_request_cmd)
+
+#define VIDIOC_MSM_ISP_CFG_STATS_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd)
+
+#define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+11, \
+ struct msm_vfe_stats_stream_release_cmd)
+
+#define VIDIOC_MSM_ISP_REG_UPDATE_CMD \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+12, enum msm_vfe_input_src)
+
+#define VIDIOC_MSM_ISP_UPDATE_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
+
+#define VIDIOC_MSM_VFE_REG_LIST_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+14, struct msm_vfe_cfg_cmd_list)
+
+#define VIDIOC_MSM_ISP_SMMU_ATTACH \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+15, struct msm_vfe_smmu_attach_cmd)
+
+#define VIDIOC_MSM_ISP_UPDATE_STATS_STREAM \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+16, struct msm_vfe_axi_stream_update_cmd)
+
+#define VIDIOC_MSM_ISP_AXI_HALT \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+17, struct msm_vfe_axi_halt_cmd)
+
+#define VIDIOC_MSM_ISP_AXI_RESET \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+18, struct msm_vfe_axi_reset_cmd)
+
+#define VIDIOC_MSM_ISP_AXI_RESTART \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+19, struct msm_vfe_axi_restart_cmd)
+
+#define VIDIOC_MSM_ISP_FETCH_ENG_START \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+20, struct msm_vfe_fetch_eng_start)
+
+#define VIDIOC_MSM_ISP_DEQUEUE_BUF \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+21, struct msm_isp_qbuf_info)
+
+#define VIDIOC_MSM_ISP_SET_DUAL_HW_MASTER_SLAVE \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+22, struct msm_isp_set_dual_hw_ms_cmd)
+
+#define VIDIOC_MSM_ISP_MAP_BUF_START_FE \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+23, struct msm_vfe_fetch_eng_start)
+
+#define VIDIOC_MSM_ISP_UNMAP_BUF \
+ _IOWR('V', BASE_VIDIOC_PRIVATE+24, struct msm_isp_unmap_buf_req)
+
+#endif /* __MSMB_ISP__ */
diff --git a/selfdrive/visiond/include/msmb_ispif.h b/selfdrive/visiond/include/msmb_ispif.h
new file mode 100644
index 00000000000000..2564c33b7b31ed
--- /dev/null
+++ b/selfdrive/visiond/include/msmb_ispif.h
@@ -0,0 +1,125 @@
+#ifndef MSM_CAM_ISPIF_H
+#define MSM_CAM_ISPIF_H
+
+#define CSID_VERSION_V20 0x02000011
+#define CSID_VERSION_V22 0x02001000
+#define CSID_VERSION_V30 0x30000000
+#define CSID_VERSION_V3 0x30000000
+
+enum msm_ispif_vfe_intf {
+ VFE0,
+ VFE1,
+ VFE_MAX
+};
+#define VFE0_MASK (1 << VFE0)
+#define VFE1_MASK (1 << VFE1)
+
+enum msm_ispif_intftype {
+ PIX0,
+ RDI0,
+ PIX1,
+ RDI1,
+ RDI2,
+ INTF_MAX
+};
+#define MAX_PARAM_ENTRIES (INTF_MAX * 2)
+#define MAX_CID_CH 8
+
+#define PIX0_MASK (1 << PIX0)
+#define PIX1_MASK (1 << PIX1)
+#define RDI0_MASK (1 << RDI0)
+#define RDI1_MASK (1 << RDI1)
+#define RDI2_MASK (1 << RDI2)
+
+
+enum msm_ispif_vc {
+ VC0,
+ VC1,
+ VC2,
+ VC3,
+ VC_MAX
+};
+
+enum msm_ispif_cid {
+ CID0,
+ CID1,
+ CID2,
+ CID3,
+ CID4,
+ CID5,
+ CID6,
+ CID7,
+ CID8,
+ CID9,
+ CID10,
+ CID11,
+ CID12,
+ CID13,
+ CID14,
+ CID15,
+ CID_MAX
+};
+
+enum msm_ispif_csid {
+ CSID0,
+ CSID1,
+ CSID2,
+ CSID3,
+ CSID_MAX
+};
+
+struct msm_ispif_params_entry {
+ enum msm_ispif_vfe_intf vfe_intf;
+ enum msm_ispif_intftype intftype;
+ int num_cids;
+ enum msm_ispif_cid cids[3];
+ enum msm_ispif_csid csid;
+ int crop_enable;
+ uint16_t crop_start_pixel;
+ uint16_t crop_end_pixel;
+};
+
+struct msm_ispif_param_data {
+ uint32_t num;
+ struct msm_ispif_params_entry entries[MAX_PARAM_ENTRIES];
+};
+
+struct msm_isp_info {
+ uint32_t max_resolution;
+ uint32_t id;
+ uint32_t ver;
+};
+
+struct msm_ispif_vfe_info {
+ int num_vfe;
+ struct msm_isp_info info[VFE_MAX];
+};
+
+enum ispif_cfg_type_t {
+ ISPIF_CLK_ENABLE,
+ ISPIF_CLK_DISABLE,
+ ISPIF_INIT,
+ ISPIF_CFG,
+ ISPIF_START_FRAME_BOUNDARY,
+ ISPIF_RESTART_FRAME_BOUNDARY,
+ ISPIF_STOP_FRAME_BOUNDARY,
+ ISPIF_STOP_IMMEDIATELY,
+ ISPIF_RELEASE,
+ ISPIF_ENABLE_REG_DUMP,
+ ISPIF_SET_VFE_INFO,
+};
+
+struct ispif_cfg_data {
+ enum ispif_cfg_type_t cfg_type;
+ union {
+ int reg_dump; /* ISPIF_ENABLE_REG_DUMP */
+ uint32_t csid_version; /* ISPIF_INIT */
+ struct msm_ispif_vfe_info vfe_info; /* ISPIF_SET_VFE_INFO */
+ struct msm_ispif_param_data params; /* CFG, START, STOP */
+ };
+};
+
+#define VIDIOC_MSM_ISPIF_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE, struct ispif_cfg_data)
+
+#endif /* MSM_CAM_ISPIF_H */
diff --git a/selfdrive/visiond/loadyuv.c b/selfdrive/visiond/loadyuv.c
new file mode 100644
index 00000000000000..2b50fb9d2a4105
--- /dev/null
+++ b/selfdrive/visiond/loadyuv.c
@@ -0,0 +1,82 @@
+#include
+#include
+
+#include "clutil.h"
+
+#include "loadyuv.h"
+
+void loadyuv_init(LoadYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height) {
+ int err = 0;
+ memset(s, 0, sizeof(*s));
+
+ s->width = width;
+ s->height = height;
+
+ char args[1024];
+ snprintf(args, sizeof(args),
+ "-cl-fast-relaxed-math -cl-denorms-are-zero "
+ "-DTRANSFORMED_WIDTH=%d -DTRANSFORMED_HEIGHT=%d",
+ width, height);
+ cl_program prg = CLU_LOAD_FROM_FILE(ctx, device_id, "loadyuv.cl", args);
+
+ s->loadys_krnl = clCreateKernel(prg, "loadys", &err);
+ assert(err == 0);
+ s->loaduv_krnl = clCreateKernel(prg, "loaduv", &err);
+ assert(err == 0);
+
+ // done with this
+ err = clReleaseProgram(prg);
+ assert(err == 0);
+}
+
+void loadyuv_destroy(LoadYUVState* s) {
+ int err = 0;
+
+ err = clReleaseKernel(s->loadys_krnl);
+ assert(err == 0);
+ err = clReleaseKernel(s->loaduv_krnl);
+ assert(err == 0);
+}
+
+void loadyuv_queue(LoadYUVState* s, cl_command_queue q,
+ cl_mem y_cl, cl_mem u_cl, cl_mem v_cl,
+ cl_mem out_cl) {
+ int err = 0;
+
+ err = clSetKernelArg(s->loadys_krnl, 0, sizeof(cl_mem), &y_cl);
+ assert(err == 0);
+ err = clSetKernelArg(s->loadys_krnl, 1, sizeof(cl_mem), &out_cl);
+ assert(err == 0);
+
+ const size_t loadys_work_size = (s->width*s->height)/8;
+ err = clEnqueueNDRangeKernel(q, s->loadys_krnl, 1, NULL,
+ &loadys_work_size, NULL, 0, 0, NULL);
+ assert(err == 0);
+
+ const size_t loaduv_work_size = ((s->width/2)*(s->height/2))/8;
+ cl_int loaduv_out_off = (s->width*s->height);
+
+ err = clSetKernelArg(s->loaduv_krnl, 0, sizeof(cl_mem), &u_cl);
+ assert(err == 0);
+ err = clSetKernelArg(s->loaduv_krnl, 1, sizeof(cl_mem), &out_cl);
+ assert(err == 0);
+ err = clSetKernelArg(s->loaduv_krnl, 2, sizeof(cl_int), &loaduv_out_off);
+ assert(err == 0);
+
+ err = clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL,
+ &loaduv_work_size, NULL, 0, 0, NULL);
+ assert(err == 0);
+
+ loaduv_out_off += (s->width/2)*(s->height/2);
+
+ err = clSetKernelArg(s->loaduv_krnl, 0, sizeof(cl_mem), &v_cl);
+ assert(err == 0);
+ err = clSetKernelArg(s->loaduv_krnl, 1, sizeof(cl_mem), &out_cl);
+ assert(err == 0);
+ err = clSetKernelArg(s->loaduv_krnl, 2, sizeof(cl_int), &loaduv_out_off);
+ assert(err == 0);
+
+ err = clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL,
+ &loaduv_work_size, NULL, 0, 0, NULL);
+ assert(err == 0);
+}
diff --git a/selfdrive/visiond/loadyuv.cl b/selfdrive/visiond/loadyuv.cl
new file mode 100644
index 00000000000000..e015429156ce91
--- /dev/null
+++ b/selfdrive/visiond/loadyuv.cl
@@ -0,0 +1,43 @@
+#define UV_SIZE ((TRANSFORMED_WIDTH/2)*(TRANSFORMED_HEIGHT/2))
+
+__kernel void loadys(__global uchar8 const * const Y,
+ __global float * out)
+{
+ const int gid = get_global_id(0);
+ const int ois = gid * 8;
+ const int oy = ois / TRANSFORMED_WIDTH;
+ const int ox = ois % TRANSFORMED_WIDTH;
+
+ const uchar8 ys = Y[gid];
+
+ // y = (x - 128) / 128
+ const float8 ysf = (convert_float8(ys) - 128.f) * 0.0078125f;
+
+ // 02
+ // 13
+
+ __global float* outy0;
+ __global float* outy1;
+ if ((oy & 1) == 0) {
+ outy0 = out; //y0
+ outy1 = out + UV_SIZE*2; //y2
+ } else {
+ outy0 = out + UV_SIZE; //y1
+ outy1 = out + UV_SIZE*3; //y3
+ }
+
+ vstore4(ysf.s0246, 0, outy0 + (oy/2) * (TRANSFORMED_WIDTH/2) + ox/2);
+ vstore4(ysf.s1357, 0, outy1 + (oy/2) * (TRANSFORMED_WIDTH/2) + ox/2);
+}
+
+__kernel void loaduv(__global uchar8 const * const in,
+ __global float8 * out,
+ int out_offset)
+{
+ const int gid = get_global_id(0);
+ const uchar8 inv = in[gid];
+
+ // y = (x - 128) / 128
+ const float8 outv = (convert_float8(inv) - 128.f) * 0.0078125f;
+ out[gid + out_offset / 8] = outv;
+}
diff --git a/selfdrive/visiond/loadyuv.h b/selfdrive/visiond/loadyuv.h
new file mode 100644
index 00000000000000..be7ea21282af3c
--- /dev/null
+++ b/selfdrive/visiond/loadyuv.h
@@ -0,0 +1,34 @@
+#ifndef LOADYUV_H
+#define LOADYUV_H
+
+#include
+#include
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ int width, height;
+ cl_kernel loadys_krnl, loaduv_krnl;
+} LoadYUVState;
+
+void loadyuv_init(LoadYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height);
+
+void loadyuv_destroy(LoadYUVState* s);
+
+void loadyuv_queue(LoadYUVState* s, cl_command_queue q,
+ cl_mem y_cl, cl_mem u_cl, cl_mem v_cl,
+ cl_mem out_cl);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LOADYUV_H
diff --git a/selfdrive/visiond/model.cc b/selfdrive/visiond/model.cc
new file mode 100644
index 00000000000000..ef1a7df9f07b90
--- /dev/null
+++ b/selfdrive/visiond/model.cc
@@ -0,0 +1,96 @@
+#include "common/timing.h"
+#include "model.h"
+
+#ifdef BIGMODEL
+ #define MODEL_WIDTH 864
+ #define MODEL_HEIGHT 288
+ #define MODEL_NAME "driving_bigmodel_dlc"
+#else
+ #define MODEL_WIDTH 320
+ #define MODEL_HEIGHT 160
+ #define MODEL_NAME "driving_model_dlc"
+#endif
+
+#define OUTPUT_SIZE 161
+
+#ifdef TEMPORAL
+ #define TEMPORAL_SIZE 512
+#else
+ #define TEMPORAL_SIZE 0
+#endif
+
+extern const uint8_t driving_model_data[] asm("_binary_" MODEL_NAME "_start");
+extern const uint8_t driving_model_end[] asm("_binary_" MODEL_NAME "_end");
+const size_t driving_model_size = driving_model_end - driving_model_data;
+
+void model_init(ModelState* s, cl_device_id device_id, cl_context context, int temporal) {
+ model_input_init(&s->in, MODEL_WIDTH, MODEL_HEIGHT, device_id, context);
+ const int output_size = OUTPUT_SIZE + TEMPORAL_SIZE;
+ s->output = (float*)malloc(output_size * sizeof(float));
+ memset(s->output, 0, output_size * sizeof(float));
+ s->m = new SNPEModel(driving_model_data, driving_model_size, s->output, output_size);
+#ifdef TEMPORAL
+ assert(temporal);
+ s->m->addRecurrent(&s->output[OUTPUT_SIZE], TEMPORAL_SIZE);
+#else
+ assert(!temporal);
+#endif
+}
+
+ModelData model_eval_frame(ModelState* s, cl_command_queue q,
+ cl_mem yuv_cl, int width, int height,
+ mat3 transform, void* sock) {
+ struct {
+ float *path;
+ float *left_lane;
+ float *right_lane;
+ float *lead;
+ } net_outputs = {NULL};
+
+ //for (int i = 0; i < OUTPUT_SIZE + TEMPORAL_SIZE; i++) { printf("%f ", s->output[i]); } printf("\n");
+
+ float *net_input_buf = model_input_prepare(&s->in, q, yuv_cl, width, height, transform);
+ s->m->execute(net_input_buf);
+
+ // net outputs
+ net_outputs.path = &s->output[0];
+ net_outputs.left_lane = &s->output[51];
+ net_outputs.right_lane = &s->output[51+53];
+ net_outputs.lead = &s->output[51+53+53];
+
+ ModelData model = {0};
+
+ for (int i=0; i 0. ? model.lead.dist : 0.;
+
+ model.lead.std = max_dist * sqrt(2.) / net_outputs.lead[1];
+ softmax(&net_outputs.lead[2], softmax_buff, 2);
+ model.lead.prob = softmax_buff[0];
+
+ return model;
+}
+
+void model_free(ModelState* s) {
+ model_input_free(&s->in);
+ delete s->m;
+}
+
diff --git a/selfdrive/visiond/model.h b/selfdrive/visiond/model.h
new file mode 100644
index 00000000000000..06a65f8539752b
--- /dev/null
+++ b/selfdrive/visiond/model.h
@@ -0,0 +1,27 @@
+#ifndef MODEL_H
+#define MODEL_H
+
+// gate this here
+//#define BIGMODEL
+#define TEMPORAL
+
+#include "common/mat.h"
+#include "common/modeldata.h"
+
+#include "commonmodel.h"
+#include "snpemodel.h"
+
+typedef struct ModelState {
+ ModelInput in;
+ float *output;
+ SNPEModel *m;
+} ModelState;
+
+void model_init(ModelState* s, cl_device_id device_id,
+ cl_context context, int temporal);
+ModelData model_eval_frame(ModelState* s, cl_command_queue q,
+ cl_mem yuv_cl, int width, int height,
+ mat3 transform, void* sock);
+void model_free(ModelState* s);
+
+#endif
diff --git a/selfdrive/visiond/monitoring.cc b/selfdrive/visiond/monitoring.cc
new file mode 100644
index 00000000000000..84ed9e8c5bb27d
--- /dev/null
+++ b/selfdrive/visiond/monitoring.cc
@@ -0,0 +1,54 @@
+#include "monitoring.h"
+#include "common/mat.h"
+
+#define MODEL_WIDTH 320
+#define MODEL_HEIGHT 160
+extern const uint8_t monitoring_model_data[] asm("_binary_monitoring_model_dlc_start");
+extern const uint8_t monitoring_model_end[] asm("_binary_monitoring_model_dlc_end");
+const size_t monitoring_model_size = monitoring_model_end - monitoring_model_data;
+
+
+void monitoring_init(MonitoringState* s, cl_device_id device_id, cl_context context) {
+ model_input_init(&s->in, MODEL_WIDTH, MODEL_HEIGHT, device_id, context);
+ s->m = new SNPEModel(monitoring_model_data, monitoring_model_size, (float*)&s->output, OUTPUT_SIZE);
+}
+
+MonitoringResult monitoring_eval_frame(MonitoringState* s, cl_command_queue q,
+ cl_mem yuv_cl, int width, int height) {
+ const mat3 front_frame_from_scaled_frame = (mat3){{
+ width/426.0f, 0.0, 0.0,
+ 0.0,height/320.0f, 0.0,
+ 0.0, 0.0, 1.0,
+ }};
+
+ const mat3 scaled_frame_from_cropped_frame = (mat3){{
+ 1.0, 0.0, 426.0-160.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0,
+ }};
+
+ const mat3 transpose = (mat3){{
+ 0.0, 1.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0,
+ }};
+
+ const mat3 front_frame_from_cropped_frame = matmul3(front_frame_from_scaled_frame, scaled_frame_from_cropped_frame);
+ const mat3 front_frame_from_monitoring_frame = matmul3(front_frame_from_cropped_frame, transpose);
+
+ float *net_input_buf = model_input_prepare(&s->in, q, yuv_cl, width, height, front_frame_from_monitoring_frame);
+ s->m->execute(net_input_buf);
+
+ MonitoringResult ret = {0};
+ memcpy(ret.vs, s->output, sizeof(ret.vs));
+ ret.std = sqrtf(2.f) / s->output[6];
+
+ return ret;
+}
+
+
+void monitoring_free(MonitoringState* s) {
+ model_input_free(&s->in);
+ delete s->m;
+}
+
diff --git a/selfdrive/visiond/monitoring.h b/selfdrive/visiond/monitoring.h
new file mode 100644
index 00000000000000..5689e7941573b5
--- /dev/null
+++ b/selfdrive/visiond/monitoring.h
@@ -0,0 +1,32 @@
+#ifndef MONITORING_H
+#define MONITORING_H
+
+#include "commonmodel.h"
+#include "snpemodel.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OUTPUT_SIZE 7
+
+typedef struct MonitoringResult {
+ float vs[6];
+ float std;
+} MonitoringResult;
+
+typedef struct MonitoringState {
+ ModelInput in;
+ SNPEModel *m;
+ float output[OUTPUT_SIZE];
+} MonitoringState;
+
+void monitoring_init(MonitoringState* s, cl_device_id device_id, cl_context context);
+MonitoringResult monitoring_eval_frame(MonitoringState* s, cl_command_queue q, cl_mem yuv_cl, int width, int height);
+void monitoring_free(MonitoringState* s);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/selfdrive/visiond/sensor_i2c.h b/selfdrive/visiond/sensor_i2c.h
new file mode 100644
index 00000000000000..c33bc3468ae5df
--- /dev/null
+++ b/selfdrive/visiond/sensor_i2c.h
@@ -0,0 +1,1830 @@
+static struct msm_camera_i2c_reg_array init_array_imx298[] = {
+ {0x101,0x0,0}, // IMAGE_ORIENT
+ {0x601,0x0,0}, // test pattern
+ //{0xb02,0,0}, // green correction?
+ // external clock setting
+ {0x136,0x18,0}, {0x137,0x0,0}, // EXCK_FREQ = Extclk_frequency_mhz
+ // global setting?
+ {0x30f4,0x1,0},
+ {0x30f5,0x7a,0},
+ {0x30f6,0x0,0},
+ {0x30f7,0xec,0},
+ {0x30fc,0x1,0},
+ {0x3101,0x1,0},
+ {0x5b2f,0x8,0},
+ {0x5d32,0x5,0},
+ {0x5d7c,0x0,0},
+ {0x5d7d,0x0,0},
+ {0x5db9,0x1,0},
+ {0x5e43,0x0,0},
+ {0x6300,0x0,0},
+ {0x6301,0xea,0},
+ {0x6302,0x0,0},
+ {0x6303,0xb4,0},
+ {0x6564,0x0,0},
+ {0x6565,0xb6,0},
+ {0x6566,0x0,0},
+ {0x6567,0xe6,0},
+ {0x6714,0x1,0},
+ {0x6758,0xb,0},
+ {0x6910,0x4,0},
+ {0x6916,0x1,0},
+ {0x6918,0x4,0},
+ {0x691e,0x1,0},
+ {0x6931,0x1,0},
+ {0x6937,0x2,0},
+ {0x693b,0x2,0},
+ {0x6d00,0x4a,0},
+ {0x6d01,0x41,0},
+ {0x6d02,0x23,0},
+ {0x6d05,0x4c,0},
+ {0x6d06,0x10,0},
+ {0x6d08,0x30,0},
+ {0x6d09,0x38,0},
+ {0x6d0a,0x2c,0},
+ {0x6d0b,0x2d,0},
+ {0x6d0c,0x34,0},
+ {0x6d0d,0x42,0},
+ {0x6d19,0x1c,0},
+ {0x6d1a,0x71,0},
+ {0x6d1b,0xc6,0},
+ {0x6d1c,0x94,0},
+ {0x6d24,0xe4,0},
+ {0x6d30,0xa,0},
+ {0x6d31,0x1,0},
+ {0x6d33,0xb,0},
+ {0x6d34,0x5,0},
+ {0x6d35,0x0,0},
+ {0x83c2,0x3,0},
+ {0x83c3,0x8,0},
+ {0x83c4,0x48,0},
+ {0x83c7,0x8,0},
+ {0x83cb,0x0,0},
+ {0xb101,0xff,0},
+ {0xb103,0xff,0},
+ {0xb105,0xff,0},
+ {0xb107,0xff,0},
+ {0xb109,0xff,0},
+ {0xb10b,0xff,0},
+ {0xb10d,0xff,0},
+ {0xb10f,0xff,0},
+ {0xb111,0xff,0},
+ {0xb163,0x3c,0},
+ {0xc2a0,0x8,0},
+ {0xc2a3,0x3,0},
+ {0xc2a5,0x8,0},
+ {0xc2a6,0x48,0},
+ {0xc2a9,0x0,0},
+ {0xf800,0x5e,0},
+ {0xf801,0x5e,0},
+ {0xf802,0xcd,0},
+ {0xf803,0x20,0},
+ {0xf804,0x55,0},
+ {0xf805,0xd4,0},
+ {0xf806,0x1f,0},
+ {0xf808,0xf8,0},
+ {0xf809,0x3a,0},
+ {0xf80a,0xf1,0},
+ {0xf80b,0x7e,0},
+ {0xf80c,0x55,0},
+ {0xf80d,0x38,0},
+ {0xf80e,0xe3,0},
+ {0xf810,0x74,0},
+ {0xf811,0x41,0},
+ {0xf812,0xbf,0},
+ {0xf844,0x40,0},
+ {0xf845,0xba,0},
+ {0xf846,0x70,0},
+ {0xf847,0x47,0},
+ {0xf848,0xc0,0},
+ {0xf849,0xba,0},
+ {0xf84a,0x70,0},
+ {0xf84b,0x47,0},
+ {0xf84c,0x82,0},
+ {0xf84d,0xf6,0},
+ {0xf84e,0x32,0},
+ {0xf84f,0xfd,0},
+ {0xf851,0xf0,0},
+ {0xf852,0x2,0},
+ {0xf853,0xf8,0},
+ {0xf854,0x81,0},
+ {0xf855,0xf6,0},
+ {0xf856,0xc0,0},
+ {0xf857,0xff,0},
+ {0xf858,0x10,0},
+ {0xf859,0xb5,0},
+ {0xf85a,0xd,0},
+ {0xf85b,0x48,0},
+ {0xf85c,0x40,0},
+ {0xf85d,0x7a,0},
+ {0xf85e,0x1,0},
+ {0xf85f,0x28,0},
+ {0xf860,0x15,0},
+ {0xf861,0xd1,0},
+ {0xf862,0xc,0},
+ {0xf863,0x49,0},
+ {0xf864,0xc,0},
+ {0xf865,0x46,0},
+ {0xf866,0x40,0},
+ {0xf867,0x3c,0},
+ {0xf868,0x48,0},
+ {0xf869,0x8a,0},
+ {0xf86a,0x62,0},
+ {0xf86b,0x8a,0},
+ {0xf86c,0x80,0},
+ {0xf86d,0x1a,0},
+ {0xf86e,0x8a,0},
+ {0xf86f,0x89,0},
+ {0xf871,0xb2,0},
+ {0xf872,0x10,0},
+ {0xf873,0x18,0},
+ {0xf874,0xa,0},
+ {0xf875,0x46,0},
+ {0xf876,0x20,0},
+ {0xf877,0x32,0},
+ {0xf878,0x12,0},
+ {0xf879,0x88,0},
+ {0xf87a,0x90,0},
+ {0xf87b,0x42,0},
+ {0xf87d,0xda,0},
+ {0xf87e,0x10,0},
+ {0xf87f,0x46,0},
+ {0xf880,0x80,0},
+ {0xf881,0xb2,0},
+ {0xf882,0x88,0},
+ {0xf883,0x81,0},
+ {0xf884,0x84,0},
+ {0xf885,0xf6,0},
+ {0xf886,0xd2,0},
+ {0xf887,0xf9,0},
+ {0xf888,0xe0,0},
+ {0xf889,0x67,0},
+ {0xf88a,0x85,0},
+ {0xf88b,0xf6,0},
+ {0xf88c,0xa1,0},
+ {0xf88d,0xfc,0},
+ {0xf88e,0x10,0},
+ {0xf88f,0xbd,0},
+ {0xf891,0x18,0},
+ {0xf892,0x21,0},
+ {0xf893,0x24,0},
+ {0xf895,0x18,0},
+ {0xf896,0x19,0},
+ {0xf897,0xb4,0},
+ {0x4e29,0x1,0},
+ // PDAF stuff
+ {0x3166,0x1,0}, //AREA_EN_0
+ {0x3167,0x1,0},
+ {0x3168,0x1,0},
+ {0x3169,0x1,0},
+ {0x316a,0x1,0},
+ {0x316b,0x1,0},
+ {0x316c,0x1,0},
+ {0x316d,0x1,0},
+ {0x3158,0x2,0},
+ {0x3159,0x2,0},
+ {0x315a,0x2,0},
+ {0x315b,0x3,0},
+ {0x3013,0x7,0}, //RMSC_NR_MODE
+ {0x3035,0x1,0},
+ {0x3051,0x0,0},
+ {0x3056,0x2,0},
+ {0x3057,0x1,0},
+ {0x3060,0x0,0},
+ {0x8435,0x0,0},
+ {0x8455,0x0,0},
+ {0x847c,0x0,0},
+ {0x84fb,0x1,0},
+ {0x9619,0xa0,0},
+ {0x961b,0xa0,0},
+ {0x961d,0xa0,0},
+ {0x961f,0x20,0},
+ {0x9621,0x20,0},
+ {0x9623,0x20,0},
+ {0x9625,0xa0,0},
+ {0x9627,0xa0,0},
+ {0x9629,0xa0,0},
+ {0x962b,0x20,0},
+ {0x962d,0x20,0},
+ {0x962f,0x20,0},
+ {0x9901,0x35,0},
+ {0x9903,0x23,0},
+ {0x9905,0x23,0},
+ {0x9906,0x0,0},
+ {0x9907,0x31,0},
+ {0x9908,0x0,0},
+ {0x9909,0x1b,0},
+ {0x990a,0x0,0},
+ {0x990b,0x15,0},
+ {0x990d,0x3f,0},
+ {0x990f,0x3f,0},
+ {0x9911,0x3f,0},
+ {0x9913,0x64,0},
+ {0x9915,0x64,0},
+ {0x9917,0x64,0},
+ {0x9919,0x50,0},
+ {0x991b,0x60,0},
+ {0x991d,0x65,0},
+ {0x991f,0x1,0},
+ {0x9921,0x1,0},
+ {0x9923,0x1,0},
+ {0x9925,0x23,0},
+ {0x9927,0x23,0},
+ {0x9929,0x23,0},
+ {0x992b,0x2f,0},
+ {0x992d,0x1a,0},
+ {0x992f,0x14,0},
+ {0x9931,0x3f,0},
+ {0x9933,0x3f,0},
+ {0x9935,0x3f,0},
+ {0x9937,0x6b,0},
+ {0x9939,0x7c,0},
+ {0x993b,0x81,0},
+ {0x9943,0xf,0},
+ {0x9945,0xf,0},
+ {0x9947,0xf,0},
+ {0x9949,0xf,0},
+ {0x994b,0xf,0},
+ {0x994d,0xf,0},
+ {0x994f,0x42,0},
+ {0x9951,0xf,0},
+ {0x9953,0xb,0},
+ {0x9955,0x5a,0},
+ {0x9957,0x13,0},
+ {0x9959,0xc,0},
+ {0x995a,0x0,0},
+ {0x995b,0x0,0},
+ {0x995c,0x0,0},
+ {0x996b,0x0,0},
+ {0x996d,0x10,0},
+ {0x996f,0x10,0},
+ {0x9971,0xc8,0},
+ {0x9973,0x32,0},
+ {0x9975,0x4,0},
+ {0x9976,0xa,0},
+ {0x9977,0xa,0},
+ {0x9978,0xa,0},
+ {0x99a4,0x2f,0},
+ {0x99a5,0x2f,0},
+ {0x99a6,0x2f,0},
+ {0x99a7,0xa,0},
+ {0x99a8,0xa,0},
+ {0x99a9,0xa,0},
+ {0x99aa,0x2f,0},
+ {0x99ab,0x2f,0},
+ {0x99ac,0x2f,0},
+ {0x99ad,0x0,0},
+ {0x99ae,0x0,0},
+ {0x99af,0x0,0},
+ {0x99b0,0x40,0},
+ {0x99b1,0x40,0},
+ {0x99b2,0x40,0},
+ {0x99b3,0x30,0},
+ {0x99b4,0x30,0},
+ {0x99b5,0x30,0},
+ {0x99bb,0xa,0},
+ {0x99bd,0xa,0},
+ {0x99bf,0xa,0},
+ {0x99c0,0x9,0},
+ {0x99c1,0x9,0},
+ {0x99c2,0x9,0},
+ {0x99c6,0x3c,0},
+ {0x99c7,0x3c,0},
+ {0x99c8,0x3c,0},
+ {0x99c9,0xff,0},
+ {0x99ca,0xff,0},
+ {0x99cb,0xff,0},
+ {0x9b01,0x35,0},
+ {0x9b03,0x14,0},
+ {0x9b05,0x14,0},
+ {0x9b07,0x31,0},
+ {0x9b09,0x1b,0},
+ {0x9b0b,0x15,0},
+ {0x9b0d,0x1e,0},
+ {0x9b0f,0x1e,0},
+ {0x9b11,0x1e,0},
+ {0x9b13,0x64,0},
+ {0x9b15,0x64,0},
+ {0x9b17,0x64,0},
+ {0x9b19,0x50,0},
+ {0x9b1b,0x60,0},
+ {0x9b1d,0x65,0},
+ {0x9b1f,0x1,0},
+ {0x9b21,0x1,0},
+ {0x9b23,0x1,0},
+ {0x9b25,0x14,0},
+ {0x9b27,0x14,0},
+ {0x9b29,0x14,0},
+ {0x9b2b,0x2f,0},
+ {0x9b2d,0x1a,0},
+ {0x9b2f,0x14,0},
+ {0x9b31,0x1e,0},
+ {0x9b33,0x1e,0},
+ {0x9b35,0x1e,0},
+ {0x9b37,0x6b,0},
+ {0x9b39,0x7c,0},
+ {0x9b3b,0x81,0},
+ {0x9b43,0xf,0},
+ {0x9b45,0xf,0},
+ {0x9b47,0xf,0},
+ {0x9b49,0xf,0},
+ {0x9b4b,0xf,0},
+ {0x9b4d,0xf,0},
+ {0x9b4f,0x2d,0},
+ {0x9b51,0xb,0},
+ {0x9b53,0x8,0},
+ {0x9b55,0x40,0},
+ {0x9b57,0xd,0},
+ {0x9b59,0x8,0},
+ {0x9b5a,0x0,0},
+ {0x9b5b,0x0,0},
+ {0x9b5c,0x0,0},
+ {0x9b6b,0x0,0},
+ {0x9b6d,0x10,0},
+ {0x9b6f,0x10,0},
+ {0x9b71,0xc8,0},
+ {0x9b73,0x32,0},
+ {0x9b75,0x4,0},
+ {0x9bb0,0x40,0},
+ {0x9bb1,0x40,0},
+ {0x9bb2,0x40,0},
+ {0x9bb3,0x30,0},
+ {0x9bb4,0x30,0},
+ {0x9bb5,0x30,0},
+ {0x9bbb,0xa,0},
+ {0x9bbd,0xa,0},
+ {0x9bbf,0xa,0},
+ {0x9bc0,0x9,0},
+ {0x9bc1,0x9,0},
+ {0x9bc2,0x9,0},
+ {0x9bc6,0x18,0},
+ {0x9bc7,0x18,0},
+ {0x9bc8,0x18,0},
+ {0x9bc9,0xff,0},
+ {0x9bca,0xff,0},
+ {0x9bcb,0xff,0},
+ {0xb2b2,0x1,0},
+};
+
+static struct msm_camera_i2c_reg_array mode_setting_array_imx298[] = {
+// i2c settings for mode 3
+// {
+// .x_output = 2328,
+// .y_output = 1748,
+// .line_length_pclk = 5536,
+// .frame_length_lines = 1802,
+// .vt_pixel_clk = 299300000,
+// .op_pixel_clk = 299300000,
+// .binning_factor = 2,
+// .min_fps = 15.000000,
+// .max_fps = 30.020000,
+// .mode = 1,
+// .offset_x = 0,
+// .offset_y = 0,
+// .scale_factor = 1.000000,
+// .is_pdaf_supported = 1,
+// }
+
+// mode settings
+
+// hdr settings
+{0x0114, 0x03, 0}, // CSI_LANE_MODE = 4-lane
+/*{0x0220, 0x00, 0}, // HDR_MODE = disable
+{0x0221, 0x11, 0}, // HDR_RESO_REDU_H/V = Full Pixel
+{0x0222, 0x10, 0}, // EXPO_RATIO = 16*/
+{0x0220, 0x01, 0}, // HDR_MODE = enable with combined gain and 16x ratio
+{0x0221, 0x22, 0}, // HDR_RESO_REDU_H/V = 2 binning
+{0x0222, 0x10, 0}, // EXPO_RATIO = 16
+
+{0x0340, 0x07, 0}, {0x0341, 0x0a, 0}, // FRM_LENGTH = frame_length_lines = 1802
+{0x0342, 0x15, 0}, {0x0343, 0xa0, 0}, // LINE_LENGTH = line_length_pclk = 5536
+{0x0344, 0x00, 0}, {0x0345, 0x00, 0}, // x_addr_start
+{0x0346, 0x00, 0}, {0x0347, 0x00, 0}, // y_addr_start
+{0x0348, 0x12, 0}, {0x0349, 0x2f, 0}, // x_addr_end
+{0x034a, 0x0d, 0}, {0x034b, 0xa7, 0}, // y_addr_end
+{0x0381, 0x01, 0}, // x_even_inc
+{0x0383, 0x01, 0}, // x_odd_inc
+{0x0385, 0x01, 0}, // y_even_inc
+{0x0387, 0x01, 0}, // y_odd_inc
+{0x0900, 0x01, 0}, // BINNING_MODE = enable
+{0x0901, 0x22, 0}, // BINING_TYPE_H/V = 2binning
+{0x0902, 0x00, 0}, // binning_weighting = average
+
+{0x0b06, 1, 0}, // SING_DEF_CORR_EN
+{0x0b0a, 1, 0}, // combined defect correct
+
+{0x3010, 0x66, 0}, // HDR_OUTPUT_CTRL = ATR + HDR compose + DPC1D + DCP2D
+{0x3011, 0x01, 0}, // HDR_OUTPUT_CTRL2 = PD enable
+{0x30c0, 0x11, 0}, // RED_GAIN_CB?
+{0x300d, 0x00, 0}, // FORCE_FDSUM = disable
+{0x30fd, 0x00, 0},
+{0x8493, 0x00, 0},
+{0x8863, 0x00, 0},
+{0x90d7, 0x19, 0},
+
+// set black level
+{0x3090, 1, 0},
+{0x3092, 0, 0},
+{0x3093, 0x38, 0},
+
+// output size settings
+{0x0112, 0x0a, 0}, {0x0113, 0x0a, 0}, // CS_DT_FMT_H = 0x0a0a (RAW10 output)
+{0x034c, 0x09, 0}, {0x034d, 0x18, 0}, // X_OUT_SIZE = 2328 (1164*2)
+{0x034e, 0x06, 0}, {0x034f, 0xd4, 0}, // Y_OUT_SIZE = 1748 (874*2)
+{0x0401, 0x00, 0}, // SCALING_MODE
+{0x0404, 0x00, 0}, {0x0405, 0x10, 0}, // SCALE_M
+{0x0408, 0x00, 0}, {0x0409, 0x00, 0}, // DCROP_XOFS
+{0x040a, 0x00, 0}, {0x040b, 0x00, 0}, // DCROP_YOFS
+{0x040c, 0x09, 0}, {0x040d, 0x18, 0}, // DCROP_WIDTH
+{0x040e, 0x06, 0}, {0x040f, 0xd4, 0}, // DCROP_HIGT
+
+// clock settings
+// 299300000
+/*
+{0x0301, 0x05, 0}, // VT_PIX_CLK_DIV
+{0x0303, 0x02, 0}, // VT_SYS_CLK_DIV
+{0x0305, 0x04, 0}, // PRE_PLL_CLK_DIV
+{0x0306, 0x00, 0}, {0x0307, 0x7d, 0}, // PLL_MULTIPLIER . mode 1: 0xf6
+{0x0309, 0x0a, 0}, // OP_PIX_CLK_DIV
+{0x030b, 0x01, 0}, // OP_SYS_CLK_DIV
+{0x030d, 0x0f, 0}, // PREPLLCK_OP_DIV
+{0x030e, 0x03, 0}, {0x030f, 0x41, 0}, // PLL_OP_MPY
+{0x0310, 0x00, 0}, // PLL_MULT_DRIV
+*/
+// 600000000
+{0x0301, 0x05, 0},
+{0x0303, 0x02, 0},
+{0x0305, 0x04, 0},
+{0x0306, 0x00, 0},
+{0x0307, 0xfa, 0},
+{0x0309, 0x0a, 0},
+{0x030b, 0x01, 0},
+{0x030d, 0x0f, 0},
+{0x030e, 0x03, 0}, {0x030f, 0x41, 0},
+{0x0310, 0x00, 0},
+
+// data rate settings
+/*{0x0820, 0x0b, 0}, // requested_link_bit_rate_mbps = 3000
+{0x0821, 0xb8, 0},
+{0x0822, 0x00, 0},
+{0x0823, 0x00, 0},*/
+{0x0820, 0x17, 0}, // requested_link_bit_rate_mbps = 6000
+{0x0821, 0x70, 0},
+{0x0822, 0x00, 0},
+{0x0823, 0x00, 0},
+
+//integration time settings
+{0x0202, 0x07, 0}, {0x0203, 0x00, 0}, // INTEG_TIME = 1792
+{0x0224, 0x01, 0}, {0x0225, 0xf4, 0}, // ST_COARSE_INTEG_TIME = 506
+
+// gain settings
+{0x0204, 0x00, 0}, {0x0205, 0x00, 0}, // ANA_GAIN_GLOBAL = 512 / (512 - X)
+{0x0216, 0x00, 0}, {0x0217, 0x00, 0}, // ST_ANA_GAIN_GLOBAL[8]
+{0x020e, 0x01, 0}, {0x020f, 0x00, 0}, // DIG_GAIN_GR
+{0x0210, 0x01, 0}, {0x0211, 0x00, 0}, // DIG_GAIN_R
+{0x0212, 0x01, 0}, {0x0213, 0x00, 0}, // DIG_GAIN_B
+{0x0214, 0x01, 0}, {0x0215, 0x00, 0}, // DIG_GAIN_GB
+
+// HDR white balance settings (ABS_GAIN)
+{0xb8e, 0x01, 0}, {0xb8f, 0x00, 0}, // GR
+{0xb90, 0x02, 0}, {0xb91, 0x2b, 0}, // R
+{0xb92, 0x01, 0}, {0xb93, 0xd4, 0}, // B
+{0xb94, 0x01, 0}, {0xb95, 0x00, 0}, // GB
+
+// phase detection settings
+{0x3058, 0x00, 0}, // NML_NR_EN
+{0x3103, 0x01, 0}, // NML_PD_CAL_ENABLE = enable
+{0x3108, 0x00, 0}, {0x3109, 0x2c, 0}, //PD_AREA_X_OFFSET
+{0x310a, 0x00, 0}, {0x310b, 0x24, 0}, //PD_AREA_Y_OFFSET
+{0x310c, 0x01, 0}, {0x310d, 0xa4, 0}, //PD_AREA_WIDTH
+{0x310e, 0x01, 0}, {0x310f, 0xa4, 0}, //PD_AREA_HEIGHT
+// whole size is 0x918 x 0x6d4
+{0x3110, 0x03, 0}, // PD_AREA_0 = 0x375-0x4d1, 0x258-0x3b6
+{0x3111, 0x75, 0},
+{0x3112, 0x02, 0},
+{0x3113, 0x58, 0},
+{0x3114, 0x04, 0},
+{0x3115, 0xd1, 0},
+{0x3116, 0x03, 0},
+{0x3117, 0xb6, 0},
+{0x3118, 0x04, 0}, // PD_AREA_1 = 0x446-0x5a2, 0x258-0x3b6
+{0x3119, 0x46, 0},
+{0x311a, 0x02, 0},
+{0x311b, 0x58, 0},
+{0x311c, 0x05, 0},
+{0x311d, 0xa2, 0},
+{0x311e, 0x03, 0},
+{0x311f, 0xb6, 0},
+{0x3120, 0x03, 0}, // PD_AREA_2 = 0x375-0x4d1, 0x32a-0x488
+{0x3121, 0x75, 0},
+{0x3122, 0x03, 0},
+{0x3123, 0x2a, 0},
+{0x3124, 0x04, 0},
+{0x3125, 0xd1, 0},
+{0x3126, 0x04, 0},
+{0x3127, 0x88, 0},
+{0x3128, 0x04, 0}, // PD_AREA_3 = 0x446-0x5a2, 0x32a-0x488
+{0x3129, 0x46, 0},
+{0x312a, 0x03, 0},
+{0x312b, 0x2a, 0},
+{0x312c, 0x05, 0},
+{0x312d, 0xa2, 0},
+{0x312e, 0x04, 0},
+{0x312f, 0x88, 0},
+{0x3130, 0x03, 0}, // PD_AREA_4 = 0x375-0x5a2, 0x258-0x488
+{0x3131, 0x75, 0},
+{0x3132, 0x02, 0},
+{0x3133, 0x58, 0},
+{0x3134, 0x05, 0},
+{0x3135, 0xa2, 0},
+{0x3136, 0x04, 0},
+{0x3137, 0x88, 0},
+{0x3138, 0x02, 0}, // PD_AREA_5 = 0x2ba-0x65d, 0x210-0x4d0
+{0x3139, 0xba, 0},
+{0x313a, 0x02, 0},
+{0x313b, 0x10, 0},
+{0x313c, 0x06, 0},
+{0x313d, 0x5d, 0},
+{0x313e, 0x04, 0},
+{0x313f, 0xd0, 0},
+{0x3140, 0x00, 0}, // PD_AREA_6 = 0xa1-0x876, 0x6b-0x676
+{0x3141, 0xa1, 0},
+{0x3142, 0x00, 0},
+{0x3143, 0x6b, 0},
+{0x3144, 0x08, 0},
+{0x3145, 0x76, 0},
+{0x3146, 0x06, 0},
+{0x3147, 0x76, 0},
+{0x3148, 0x00, 0}, // PD_AREA_7 = 0xa1-0x876, 0x5e-0x34c
+{0x3149, 0xa1, 0},
+{0x314a, 0x00, 0},
+{0x314b, 0x5e, 0},
+{0x314c, 0x08, 0},
+{0x314d, 0x76, 0},
+{0x314e, 0x03, 0},
+{0x314f, 0x4c, 0},
+{0x3165, 0x02, 0}, // AREA_EN_0 = free area
+};
+
+// static struct msm_camera_i2c_reg_array reg_array3[] = {
+// // REG_HOLD ON
+// {0x104,0x1,0},
+// // from regression
+// {0x3002,0x0,0},
+// // FRM_LENGTH, 1802 vs 3554
+// // {0x340,0x7,0}, {0x341,0xa,0}, // camera start {0x340,0xd,0}, {0x341,0xe2,0},
+// // INTEG_TIME aka coarse_int_time_addr aka shutter speed
+// {0x202,0x03,0}, {0x203,0xda,0},
+// // global_gain_addr
+// {0x204,0x0,0}, {0x205,0x0,0},
+
+// //??
+// {0x20e,0x1,0}, {0x20f,0x0,0},
+// {0x210,0x1,0}, {0x211,0x0,0},
+// {0x212,0x1,0}, {0x213,0x0,0},
+// {0x214,0x1,0}, {0x215,0x0,0},
+
+// // REG_HOLD: mode setting
+// {0x104,0x0,0},
+// };
+
+// start, remove standby mode
+static struct msm_camera_i2c_reg_array start_reg_array[] = {{0x100,0x1,0}};
+
+// stop, enable standby mode
+static struct msm_camera_i2c_reg_array stop_reg_array[] = {{0x100,0x0,0}};
+
+
+///////////////////
+
+
+static struct msm_camera_i2c_reg_array init_array_imx179[] = {
+ { 0x100, 0x0, 0}, // MODE_SELECT
+ { 0x101, 0x0, 0}, // IMAGE_ORIENT
+ { 0x202, 0x9, 0}, { 0x203, 0xd2, 0}, // COARSE_INTEGRATION_TIME
+ { 0x301, 0x5, 0}, // vt_pix_clk_div
+ { 0x303, 0x1, 0}, // vt_sys_clk_div
+ { 0x305, 0x6, 0}, // pre_pll_clk_div
+ { 0x309, 0x5, 0}, // op_pix_clk_div
+ { 0x30b, 0x1, 0}, // op_sys_clk_div
+ { 0x30c, 0x0, 0}, { 0x30d, 0x9d, 0},
+
+ { 0x340, 0x9, 0}, { 0x341, 0xd6, 0}, // frame_length_lines
+ { 0x342, 0xd, 0}, { 0x343, 0x70, 0}, // line_length_pclk
+ { 0x344, 0x0, 0}, { 0x345, 0x0, 0}, // x_addr_start
+ { 0x346, 0x0, 0}, { 0x347, 0x0, 0}, // y_addr_start
+ { 0x348, 0xc, 0}, { 0x349, 0xcf, 0}, // last_pixel / x_addr_end
+ { 0x34a, 0x9, 0}, { 0x34b, 0x9f, 0}, // last_line / y_addr_end
+ { 0x34c, 0xc, 0}, { 0x34d, 0xd0, 0}, // pixels_per_line / x_output_size
+ { 0x34e, 0x9, 0}, { 0x34f, 0xa0, 0}, // lines_per_frame / y_output_size
+ { 0x383, 0x1, 0}, // x_odd_inc
+ { 0x387, 0x1, 0}, // y_odd_inc
+ { 0x390, 0x0, 0}, // binning_mode
+ { 0x401, 0x0, 0}, // SCALING_MODE
+ { 0x405, 0x10, 0}, // SCALE_M
+
+ {0x3020, 0x10, 0},
+ {0x3041, 0x15, 0}, // READ_MODE?
+ {0x3042, 0x87, 0},
+ {0x3089, 0x4f, 0},
+ {0x3309, 0x9a, 0},
+ {0x3344, 0x57, 0},
+ {0x3345, 0x1f, 0},
+ {0x3362, 0xa, 0},
+ {0x3363, 0xa, 0},
+ {0x3364, 0x0, 0},
+ {0x3368, 0x18, 0},
+ {0x3369, 0x0, 0},
+ {0x3370, 0x6f, 0},
+ {0x3371, 0x27, 0},
+ {0x3372, 0x4f, 0},
+ {0x3373, 0x2f, 0},
+ {0x3374, 0x27, 0},
+ {0x3375, 0x2f, 0},
+ {0x3376, 0x97, 0},
+ {0x3377, 0x37, 0},
+ {0x33c8, 0x0, 0},
+ {0x33d4, 0xc, 0},
+ {0x33d5, 0xd0, 0},
+ {0x33d6, 0x9, 0},
+ {0x33d7, 0xa0, 0},
+ // znr
+ {0x4100, 0xe, 0},
+ {0x4108, 0x1, 0},
+ {0x4109, 0x7c, 0},
+};
+
+
+
+/////////////// ois stuff ///////////////
+
+/*
+#define _OP_FIRM_DWNLD 0x80
+#define _OP_Periphe_RW 0x82
+#define _OP_Memory__RW 0x84
+#define _OP_AD_TRNSFER 0x86
+#define _OP_COEF_DWNLD 0x88
+#define _OP_PrgMem__RD 0x8A
+#define _OP_SpecialCMD 0x8C
+*/
+
+static struct reg_settings_ois_t ois_init_settings[] = {
+ {
+ .reg_addr = 0x8262,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0xbf03,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8263,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x9f05,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8264,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x6040,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8260,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x1130,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8265,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x8000,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8261,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0280,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8261,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0380,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8261,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0988,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x34\x84\x00\x03\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x03\x00\x10\x7e\x84\x50\x00\x08\x40\x7e\xa0\x00\x03\x00\x10\x7e\x84\x60\x00\x08\x40\x7e\xa0\x00\x03\x00\x90\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x10\x08\x80\x00\xa0\x10\x00\x08\x7f\xff\x11\x8f\x02\x07\x80\x00\x11\x40\xff\xa0\x90\x01\x84\x20\x8f\x08\x40\xfe\x90\x40\xf5",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x08\x80\x01\xa0\x00\x01\x11\x8f\x02\x07\xff\xff\x11\x08\x00\x20\x50\x12\x07\x00\x10\x08\x80\x00\xa0\x10\xff\x84\x20\x0a",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x7f\xff\x21\x08\xfe\x84\x00\x04\x07\x20\x0c\x08\x7f\xff\x21\x08\xfe\x84\x00\x03\x00\x90\x17\x84\x20\x1f\x08\x80\x17\xa0\x10\x10",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x7f\xff\x21\x10\x00\x08\x01\x00\x11\x40\x51\xa0\x90\x17\x84\x20\x0f\x08\x80\x47\xa0\x8d\x0c\x07\x00\x00\x11\x30\x03\x07\x80\x41",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8090,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x50\x00\x08\x40\xfc\x90\x88\x2f\x84\x00\x00\x11\x30\x02\x07\x40\xff\x90\x50\x00\x08\x40\xfd\x90\x40\x7f\xa0\x10\xff\x84\x20\x2c",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x7f\xff\x11\x20\x0d\x08\x80\x0f\x90\x80\x26\xa0\x90\x2e\x84\x00\x10\x08\x90\x26\x84\x00\x10\x08\x80\x1f\xa0\x20\x2e\x08\x40\xed",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8090,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x20\x0f\x08\x80\x0e\x90\x00\x00\x21\x30\x02\x07\x40\xeb\xa0\x50\x00\x08\x40\xfe\x90\x40\x7f\xa0\x04\xeb\x84\x10\x00\x20\x20\x0f",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x80\x00\x21\x60\x04\x07\x40\xff\xa0\x10\x00\x08\x40\xea\x90\x10\x00\x20\x20\x0f\x08\x80\x00\x11\x00\x0b\x07\x08\x00\x20\x60\x0d",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x00\x08\x40\xea\x90\x8f\x06\x07\x04\xff\x84\x20\x09\x60\x10\xfc\x84\x08\xfd\x84\x04\xfe\x84\x00\x03\x00\x00\x10\x08\x80\x37",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x90\x69\x84\x00\x10\x08\x80\x69\xa0\x20\x1a\x08\x40\x64\xa0\x10\x10\x08\x80\x4f\xa0\x20\x1d\x08\x40\x5f\xa0\x20\x1e\x08\x40\x5d",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x00\x08\x80\x68\x90\x40\xfe\xa0\x20\x0e\x07\x50\x00\x08\x40\x7f\xa0\x04\xfe\x84\x00\x04\x00\x10\xf0\x44\x50\x00\x08\x00\x7f",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x20\xf0\x60\x04\x5c\x84\x04\x61\x84\x04\x57\x84\x00\x00\x21\x04\x74\x84\x00\x40\x21\x00\x0b\x07\x04\x74\x84\x00\x00\x21\x10\x57",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x30\x20\x08\x00\x04\x11\x50\x00\x08\x03\xff\x11\x20\xfa\x60\x10\xf0\x44\x50\x20\x08\x00\x7f\x11\x60\x20\x08\x40\x00\x08\x00\x08",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x30\x1a\x07\x50\x00\x08\x07\x00\x11\x9f\x1d\x07\x8b\x1e\x07\x9c\x15\x07\x20\xf8\x60\x10\x28\x44\x60\x00\x08\x01\x00\x11\x20\x28",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8060,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x87\x1b\x07\x40\xf7\xa0\x81\x27\x07\x20\x48\x60\x10\x0a\x44\x10\xf4\x84\x3b\xd4\x00\xe0\x14\x43\x08\x00\x20\x00\x06\x07\x89\x02",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\xae\x90\x81\x04\x07\x40\x2e\x90\x40\x7f\xa0\x10\x2e\x44\x20\x2f\x08\x9f\x02\x07\x00\x00\x11\x10\x00\x20\x00\x00\x08\x40\x67",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x11\x84\x02\x07\x20\xf0\x60\x9f\x03\x07\x40\x7e\xa0\x40\x65\x90\x10\x62\x84\x10\x10\x08\x40\x61\xa0\x20\x1d\x08\x40\x5f",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x20\x1e\x08\x40\x5d\xa0\x10\x00\x08\x40\x5e\x90\x20\x30\x60\x10\xcf\x84\x20\x1c\x08\x7f\xff\x21\x3b\xf7\x00\xc8\x14\x43\x10\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8020,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x08\x40\xb5\x90\x40\xad\xa0\x00\x0a\x07\x10\x4f\x84\x20\x1c\x08\x7f\xff\x21\x3c\x01\x00\x48\x14\x43\x10\x00\x20\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x35\x90\x40\x2d\xa0\x00\x14\x07\x80\x0c\x07\x82\x03\x07\x04\x50\x84\x10\x00\x20\x20\x02\x07\x00\x08\x21\x40\x00\x08\x00\x01",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x50\xa0\x00\x04\x00\x20\x7f\x00\x80\x14\x43\x01\x00\x01\x04\x00\x11\x02\x00\x21\x10\x9f\x84\x10\x20\x08\x40\x97\x90\x10\xbf",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x20\x1d\x08\x40\xc6\xa0\x20\x8e\x08\x40\x72\x90\x40\x16\xa0\x10\x96\x84\x10\x00\x08\x40\x9e\x90\x20\x36\x60\x20\x91\x00\x00\x14",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8043,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x01\x01\x00\x04\x11\x00\x02\x21\x10\x1f\x84\x10\x20\x08\x40\x17\x90\x10\x3f\x84\x20\x1d\x08\x40\x46\xa0\x20\x8e\x08\x40\x70",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8090,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x96\xa0\x10\x16\x84\x10\x00\x08\x40\x1e\x90\x20\x34\x60\x10\x65\x84\x50\x10\x08\x00\x00\x21\x84\x03\x07\x20\xf0\x60\x9f\x03",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x7e\xa0\x00\x10\x08\x40\x65\xa0\x20\x0d\x08\x40\x64\x90\x40\x62\xa0\x00\x04\x00\x04\x1c\x44\x04\x1b\x44\xc3\xff\x21\x87\x04",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x7f\xa0\x10\x42\x84\x20\x1e\x08\x7f\xff\x21\x10\x20\x08\x40\x1c\x90\x10\x07\x84\x10\x00\x08\x40\x06\x90\x40\x55\xa0\x10\xc2",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x20\x1e\x08\x7f\xff\x21\x10\x20\x08\x40\x9c\x90\x10\x87\x84\x10\x00\x08\x40\x86\x90\x40\x56\xa0\x10\x56\x84\x20\x0f\x08\x40\x7b",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8090,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x22\x00\x60\x40\x00\x08\x40\x79\xa0\x00\x08\x11\x10\x55\x84\x20\x0f\x08\x40\x7a\x90\x22\x00\x60\x50\x00\x08\x40\x79\xa0\x00\xff",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x04\x6f\x84\x00\x05\x21\x21\x39\x00\x04\x00\x11\x10\xc1\x84\x20\x0f\x08\x70\x07\x07\x10\x10\x08\x40\xc0\xa0\x20\x0f\x08\x7f\xff",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x8f\x02\x07\x80\x00\x11\x08\x00\x20\x08\xc1\x84\x40\xbd\x90\x9e\x02\x07\x40\x7f\xa0\x40\xec\x90\x04\x6e\x84\x00\x05\x21\x21\x4c",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x04\x11\x10\x41\x84\x20\x0f\x08\x70\x07\x07\x10\x10\x08\x40\x40\xa0\x20\x0f\x08\x7f\xff\x11\x8f\x02\x07\x80\x00\x11\x08\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8020,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x08\x41\x84\x40\x3d\x90\x9e\x02\x07\x40\x7f\xa0\x40\x6d\x90\x10\x2d\x44\x20\xe7\x00\x08\x00\x11\x20\x32\x60\x80\x14\x43\x10\x2c",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8044,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x20\xec\x00\x00\x08\x11\x20\x31\x60\x00\x14\x43\x04\x34\x44\x40\x5b\xa0\x00\x04\x00\x21\x6a\x00\x80\x00\x11\x21\x70\x00\x3f\xff",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x08\xe8\x84\x20\x32\x50\x08\x68\x84\x20\x31\x50\x08\x5e\x84\x20\x30\x50\x0f\xc4\x07\x10\x34\x44\x10\x5b\x84\x6f\xf3\x07\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x02\x00\x21\x40\xfc\x90\x3d\xd4\x00\x04\xfc\x84\x00\x00\x21\x04\xfd\x84\x00\x08\x21\x00\x04\x00\x21\x81\x00\xc0\x00\x11\x04\x5b",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x02\x00\x21\x70\x06\x07\x10\xfe\x84\x30\x20\x08\x00\x03\x11\x10\x00\x08\x40\x59\x90\x04\xff\x84\x40\x58\xa0\x10\x59\x84\x20\x0f",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x59\xa0\x20\x00\x11\x70\x1e\x07\x10\x00\x08\x00\x0b\x11\x0f\xe4\x07\x10\x59\x84\x00\x00\x08\x20\x30\x50\x40\x59\xa0\x70\x06",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x00\x08\x00\x0a\x11\x0f\xec\x07\x08\x34\x44\x02\x10\x11\x10\x58\x84\x20\x0f\x08\x40\x58\xa0\x20\x00\x11\x30\x08\x07\x0f\xf4",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x58\x84\x00\x00\x08\x20\x30\x50\x40\x58\xa0\x70\x06\x07\x10\x00\x08\x00\x05\x11\x00\x04\x00\x10\x5a\x84\x00\x00\x08\x00\x01",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x5a\xa0\x08\x34\x44\x02\x00\x11\x30\x08\x07\x60\x00\x08\x00\x00\x11\x40\x5a\xa0\x8f\x4f\x07\x40\x7e\xa0\x00\x04\x00\x3c\xdd",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x00\x20\xa8\x14\x43\x04\xa7\x84\x20\x8e\x08\x40\xc4\x90\x40\xaf\xa0\x20\x0f\x08\x40\xc5\x90\x40\xa7\xa0\x3c\xe7\x00\x10\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8020,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x28\x14\x43\x04\x27\x84\x20\x8e\x08\x40\x44\x90\x40\x2f\xa0\x20\x0f\x08\x40\x45\x90\x40\x27\xa0\x00\x04\x00\x10\xf0\x44\x50\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\xff\xf7\x11\x93\x04\x07\x20\xf0\x60\x04\x61\x84\x04\x5c\x84\x40\x57\xa0\x00\x04\x00\x10\x61\x84\x00\x20\x08\x20\x1f\x08\x40\xff",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x00\x08\x40\x5c\x90\x40\x57\xa0\x04\x74\x84\x10\x00\x20\x00\x00\x08\x40\x74\xa0\x00\x01\x11\x20\x05\x07\x00\x40\x21\x70\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x7f\xff\x21\x08\xff\x84\x42\x00\x90\x85\x02\x07\x20\xf0\x60\x7f\xff\x11\x60\x20\x08\x00\xd0\x11\x40\x00\x08\x00\x02\x11\x86\x1b",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x74\xa0\x08\x6f\x84\x00\x00\x11\x04\xf1\x84\x00\x40\x21\x21\xf7\x00\x02\x00\x11\x60\x07\x07\x10\x20\x08\x40\xc3\x90\x20\x2f",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x80\x00\x11\x70\x02\x07\x7f\xff\x11\x10\x00\x08\x40\x8d\x90\x40\x85\xa0\x08\x6e\x84\x00\x00\x11\x04\xf0\x84\x00\x40\x21\x22\x07",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x02\x11\x60\x07\x07\x10\x20\x08\x40\x43\x90\x20\x2f\x08\x80\x00\x11\x70\x02\x07\x7f\xff\x11\x10\x00\x08\x40\x0d\x90\x40\x05",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\xec\x84\x00\x10\x08\x10\xe7\x84\x40\xe7\xa0\x20\x0f\x08\x40\xef\xa0\x10\x6d\x84\x00\x10\x08\x10\x6c\x84\x40\x6c\xa0\x20\x0f",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x7d\xa0\x7f\xff\x11\x00\x04\x00\x10\xef\x84\x00\x10\x08\x10\xee\x84\x40\xee\xa0\x20\x0f\x08\x40\xbd\xa0\x10\x7d\x84\x00\x10",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x7c\x84\x40\x7c\xa0\x20\x0f\x08\x40\x3d\xa0\x40\x00\x11\x3e\x9b\x00\xfb\xff\x21\x6f\x14\x43\x3e\x9e\x00\xff\xfb\x21\x6e\x14",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8043,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x3d\x57\x00\x40\xaf\xa0\xa0\x14\x43\x3d\x5a\x00\x40\x2f\xa0\x20\x14\x43\x00\x04\x00\x3d\x5e\x00\x40\xa5\xa0\xb0\x14\x43\x3d\x61",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x25\xa0\x30\x14\x43\x00\x00\x00\x22\x28\x00\x00\x02\x07\x22\x26\x00\x8a\x03\x07\x89\x04\x07\x40\x7e\xa0\x40\xbd\x90\x98\x14",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8043,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x9c\x84\x20\x8f\x08\x40\x9a\x90\x40\x99\xa0\x20\x2e\x08\x40\xbd\x90\x00\x10\x08\x40\x9b\xa0\x20\x0e\x08\x7f\xff\x21\x40\xf5",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8090,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x22\x3c\x00\x00\x02\x07\x22\x3a\x00\x82\x03\x07\x81\x04\x07\x40\x7e\xa0\x40\x3d\x90\x18\x14\x43\x10\x1c\x84\x20\x8f",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8008,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x1a\x90\x40\x19\xa0\x20\x2e\x08\x40\x3d\x90\x00\x10\x08\x40\x1b\xa0\x20\x0e\x08\x7f\xff\x21\x40\xf5\x90\x3d\x8c\x00\xb8\x14",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8043,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\xc2\xa0\x3d\x8f\x00\x38\x14\x43\x40\x42\xa0\x00\x04\x00\x10\x51\x84\x20\x0f\x08\x7f\xc0\x11\x40\x51\xa0\x08\xbb\x84\x08\x3b",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\xcb\x90\x11\x9e\x02\x07\xc7\x00\x11\x40\x7f\xa0\x08\xba\x84\x08\x3a\x84\x74\x70\x11\x9e\x02\x07\x59\x00\x11\x40\x7f\xa0\x3e\xed",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\xfd\xff\x21\xf1\x14\x43\x3e\xf0\x00\xff\xfd\x21\xf0\x14\x43\x00\x04\x00\x04\xb9\x84\x40\xb6\xa0\x04\x39\x84\x40\x36\xa0\x00\x04",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x3e\xc3\x00\x40\x87\xa0\x80\x14\x43\x3e\xc6\x00\x40\x07\xa0\x00\x14\x43\x00\x04\x00\x00\x00\x00\x04\xf5\x84\x00\x00\x21\x70\x03",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\xf5\x84\x10\x00\x08\x40\xf3\x90\x40\xf5\xa0\x3e\xd2\x00\x40\x85\xa0\x88\x14\x43\x3e\xd5\x00\x40\x05\xa0\x08\x14\x43\x00\x04",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8000,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x01\x07\x00\x02\x07\x00\x03\x07\x00\x04\x07\x00\x06\x07\x00\x16\x07\x00\x1e\x07\x00\x24\x07\x00\x3c\x07\x00\x72\x07\x00\x8d",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\xe0\x07\x00\xf6\x07\x01\x9f\x07\x01\xd1\x07\x00\x10\x07\x1f\xff\x07\x20\x03\x60\x0f\x5f\x07\x08\xfa\x84\x04\x11\x44\xff\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x2f\x63\x07\x70\x10\x08\x00\xf0\x21\x50\x00\x08\x00\xf0\x21\x40\xf9\x90\x00\x08\x07\x3e\x79\x00\x0f\x6b\x07\x90\x01\x07\x40\xf9",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x80a0,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x3f\x6e\x07\x70\x00\x08\x00\x7f\x11\x40\xf8\xa0\x9d\x07\x07\x20\x12\x60\x08\xfa\x84\x04\x11\x44\x3e\x54\x00\x00\x16\x07\x48\x80",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x08\x09\x44\x40\x75\x90\x7f\xef\x07\x10\x00\x20\x00\x10\x08\xff\xff\x21\x06\x00\x84\x40\xfb\xa0\x60\x00\x08\x00\x00\x21\x40\xff",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8090,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\xfb\x84\x60\x20\x08\x40\xfb\x90\x30\x00\x08\x00\x08\x11\x3d\xea\x00\x04\xfb\x84\x3d\xec\x00\x04\xff\x84\x40\xf8\xa0\x04\x11",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8044,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x8f\xff\x07\x20\x19\x60\x3e\xd2\x00\x00\x31\x07\x00\x01\x00\x00\x33\x07\x00\x02\x00\x27\x18\x43\x75\x00\x43\x8f\xff\x07\x20\x19",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8060,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x04\xf5\x84\x40\xf2\xa0\x04\x51\x84\x7f\xff\x21\x04\xf5\x84\x00\x00\x21\x04\xf3\x84\x00\x10\x21\x04\xf2\x84\x0c\x00\x21\x04\x72",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8044,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x77\x21\x3f\xfa\x07\x70\x20\x08\x00\x00\x11\x10\x2d\x44\x10\x2c\x44\x00\x20\x08\x10\x00\x11\x00\x00\x08\x00\x00\x11\x80\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8021,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x04\x73\x44\x07\x07\x21\x04\x72\x44\x00\x07\x21\x04\x73\x44\x07\x77\x21\x04\x73\x44\x00\x70\x21\x04\x2e\x44\x04\x2d\x44\x04\x2c",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8044,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x80\x00\x21\x04\x1c\x44\x04\x1b\x44\x0d\x00\x21\x04\x1c\x44\x04\x1b\x44\x0c\x80\x21\x04\x1c\x44\x04\x1b\x44\x1f\x08\x21\x0f\x18",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8043,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x08\x28\x44\x01\x11\x11\x08\x5d\x84\x10\x00\x10\x10\x00\x08\x40\x00\x21\x30\x04\x07\x40\xff\x90\x50\x20\x08\xc0\x00\x11\x10\xff",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x20\x08\x00\x40\x11\x40\x00\x08\x00\x01\x11\x20\x51\x60\x10\x00\x44\x60\x00\x08\x40\x54\x90\x20\x00\x60\x00\x79\x07\x81\x48",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x80\x03\x07\x40\xf8\xa0\x48\xc0\x11\x00\x77\x07\x00\x78\x07\x00\x79\x07\x00\x04\x07\x00\x7b\x07\x00\x7c\x07\x00\x7d\x07\x00\x55",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8007,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x7f\x07\x00\x80\x07\x00\x81\x07\x00\x74\x07\x00\x83\x07\x00\x82\x07\x00\x85\x07\x00\x86\x07\x0f\xef\x07\x1f\xff\x07\xff\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8011,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x10\x00\x20\x30\x10\x08\x00\x01\x21\x50\x00\x08\x00\x0f\x21\x40\xf9\x90\x30\x90\x07\x70\x10\x08\x00\x80\x21\x50\x00\x08\x00\xf0",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8021,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x08\xf9\x84\x04\xf8\x84\x2f\xff\x07\x3e\x59\x00\x04\xf1\x84\x04\xf0\x84\x04\x5a\x84\x00\x00\x21\x04\xf6\x84\x00\x02\x21\x04\xfa",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8084,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x40\x00\x21\x04\xf7\x84\x01\x04\x21\x04\x1c\x44\x04\x1b\x44\x0b\x23\x21\x0f\x18\x43\x04\x70\x44\x06\x66\x21\x04\x3b\x44\x04\x39",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8044,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x80\x21\x04\x3c\x44\x2a\x0a\x21\x04\x2f\x44\x00\x44\x21\x04\x29\x44\x00\x00\x21\x03\x19\x42\x4e\x19\x43\x0c\x59\x43\x27\x18",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8043,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x15\x00\x43\x04\x22\x44\x03\x07\x21\x04\x21\x44\x11\x11\x21\x04\x20\x44\x33\x33\x21\x00\x00\x42\xc0\x3d\x42\x80\x3d\x43\x04\x35",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8044,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x21\x04\x05\x43\x42\xcd\x00",
+ .reg_data_seq_size = 9,
+ },{
+ .reg_addr = 0x88ef,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x20\x00\x18\x00\x00\x00\x00\xab\x0a\x00\x40\x00\x40\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x27\x83\x64\x7e\xca\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x88b2,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x7f\x59\x7f\xbe\x7f\xfe\x7f\xfe\x7f\xee\x73\x54\x4c\x70\x5a\x00\x6b\x0e\x6b\x1c\x5b\xcb\x32\x8c\x0b\xd2\x13\x07\x28\x01\x49\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\xff\x7f\x0b\x97\x14\xae\xf7\x53\x26\x63\x07\x46\x00\x20\x00\x89\x00\x40\x80\x41\x00\x7f\xff\x7f\xd3\x09\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x88ff,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x7f\x00\x00\x00\x00\x90\xcb\x70\x74\xfe\x7f\x52\x09\x00\x00\xfe\x7f\x00\x00\x00\x00\x00\xf2\x00\x40\xf0\x7f\x00\x0c\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x4a\x00\x4a\x00\x24\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x00\x50\x00\x30\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\xa0\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\xff\x7f\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\xff\x7f\x00\x78\x00\x08\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x40\x00\x40\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x80\xff\x7f\x1c\x1b\xc5\x07\xc0\x20\x12\xf0\x00\x10\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\xcc\x59\x00\x00\x00\x40\x00\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x0b",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8897,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x14\xae\xf7\x53\x26\x63\x07\x46\x00\x20\x00\x89\x00\x40\x80\x41\x00\x7f\xff\x7f\xd3\x09\x00\x00\xff\x7f\x00\x00\x00\x00\x90\xcb",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8870,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x74\xfe\x7f\x52\x09\x00\x00\xfe\x7f\x00\x00\x00\x00\x00\xf2\x00\x40\xf0\x7f\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4a\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x884a,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x24\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x00\x50\x00\x30\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x00\x00\x03",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8800,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\xff\x7f\x00\x00\x00\x00\x00\x00\xff\x7f\x00",
+ .reg_data_seq_size = 32,
+ },{
+ .reg_addr = 0x8878,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0000,
+ .data_type = MSM_CAMERA_I2C_SEQ_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "\x00\x08\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x40\x00\x40",
+ .reg_data_seq_size = 18,
+ },{
+ .reg_addr = 0x8205,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0c00,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8205,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0d00,
+ .data_type = MSM_CAMERA_I2C_WORD_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ },{
+ .reg_addr = 0x8c01,
+ .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
+ .reg_data = 0x0001,
+ .data_type = MSM_CAMERA_I2C_BYTE_DATA,
+ .i2c_operation = MSM_OIS_WRITE,
+ .delay = 0,
+ .reg_data_seq = "",
+ .reg_data_seq_size = 0,
+ }
+};
+
+
+/*
+// still mode settings:
+ {0x847f, 0x0c0c,}, //_M_EQCTL
+
+ {0x8436, 0xfd7f,}, //_M_Kgxdr
+ {0x8440, 0xf07f,}, //_M_X_LMT
+ {0x8443, 0xb41e,}, //_M_X_TGT
+ {0x841b, 0x4001,}, //_M_Kgx10
+
+ {0x84b6, 0xfd7f,}, //_M_Kgydr
+ {0x84c0, 0xf07f,}, //_M_Y_LMT
+ {0x84c3, 0xb41e,}, //_M_Y_TGT
+ {0x849b, 0x4001,}, //_M_Kgy10
+
+ {0x8438, 0x2d0f,}, //_M_Kgx11
+ {0x84b8, 0x2d0f,}, //_M_Kgy11
+ {0x8447, 0x002b,}, //_M_KgxTG
+ {0x84c7, 0x002b,}, //_M_KgyTG
+
+ {0x847f, 0x0d0d,}, //_M_EQCTL
+*/
+
+static struct msm_camera_i2c_reg_array init_array_s5k3p8sp[] = {
+ {0x6028,0x2000,0}, {0x6214,0x7971,0}, {0x6218,0x7150,0}, {0x30e,0x3d,0},
+ {0x6028,0x2000,0}, {0x602a,0x2f38,0}, {0x6f12,0x88,0}, {0x6f12,0xd70,0},
+ {0x344,0x18,0},
+ {0x348,0x1217,0}, // last_pixel = 0x90C*2
+ {0x346,0x18,0},
+ {0x34a,0xd97,0}, // last_line = 0x6CC*2
+ {0x34c,0x900,0}, // width?
+ {0x34e,0x6c0,0}, // height?
+ {0x342,0x1400,0}, // line_length_pclk
+ {0x340,0xe3b,0}, // frame_length_lines
+ {0x202,0x200,0}, // integ_time
+ {0x200,0x618,0},
+ {0x900,0x122,0}, {0x380,0x1,0}, {0x382,0x3,0}, {0x384,0x3,0}, {0x386,0x1,0}, {0x400,0x0,0}, {0x404,0x10,0},
+ {0x3604,0x2,0}, {0x3606,0x103,0}, {0xf496,0x48,0}, {0xf470,0x20,0}, {0xf43a,0x15,0}, {0xf484,0x6,0}, {0xf440,0xaf,0}, {0xf442,0x44c6,0},
+ {0xf408,0xfff7,0}, {0x3664,0x19,0}, {0xf494,0x1010,0}, {0x367a,0x100,0}, {0x362a,0x104,0}, {0x362e,0x404,0}, {0x32b2,0x8,0}, {0x3286,0x3,0}, {0x328a,0x5,0},
+ {0xf47c,0x1f,0}, {0xf62e,0xc5,0}, {0xf630,0xcd,0}, {0xf632,0xdd,0}, {0xf634,0xe5,0}, {0xf636,0xf5,0}, {0xf638,0xfd,0}, {0xf63a,0x10d,0}, {0xf63c,0x115,0}, {0xf63e,0x125,0}, {0xf640,0x12d,0},
+ {0x6028,0x2000,0}, {0x602a,0x1704,0}, {0x6f12,0x8011,0}, {0x3070,0x0,0}, {0xb0e,0x0,0}, {0x317a,0x7,0}, {0x31c0,0xc8,0}, {0x1006,0x4,0}, {0x31a4,0x102,0},
+};
+
+static struct msm_camera_i2c_reg_array init_array_ov8865[] = {
+// round 1
+//{0x103,0x1,0}, // software reset
+{0x100,0x0,0}, // standby on
+{0x3638,0xff,0},
+{0x302,0x1e,0}, {0x303,0x0,0}, {0x304,0x3,0}, {0x30d,0x1e,0}, {0x30e,0x0,0}, {0x30f,0x9,0}, {0x312,0x1,0}, {0x31e,0xc,0}, // PLL control
+{0x3015,0x1,0}, {0x3018,0x72,0}, {0x3020,0x93,0}, {0x3022,0x1,0},
+{0x3031,0xa,0}, // 10-bit mode
+{0x3106,0x1,0}, {0x3305,0xf1,0}, {0x3308,0x0,0}, {0x3309,0x28,0}, {0x330a,0x0,0}, {0x330b,0x20,0}, {0x330c,0x0,0}, {0x330d,0x0,0}, {0x330e,0x0,0}, {0x330f,0x40,0}, {0x3307,0x4,0}, {0x3604,0x4,0}, {0x3602,0x30,0}, {0x3605,0x0,0}, {0x3607,0x20,0}, {0x3608,0x11,0}, {0x3609,0x68,0}, {0x360a,0x40,0}, {0x360c,0xdd,0}, {0x360e,0xc,0}, {0x3610,0x7,0}, {0x3612,0x86,0}, {0x3613,0x58,0}, {0x3614,0x28,0}, {0x3617,0x40,0}, {0x3618,0x5a,0}, {0x3619,0x9b,0}, {0x361c,0x0,0}, {0x361d,0x60,0}, {0x3631,0x60,0}, {0x3633,0x10,0}, {0x3634,0x10,0}, {0x3635,0x10,0}, {0x3636,0x10,0}, {0x3641,0x55,0}, {0x3646,0x86,0}, {0x3647,0x27,0}, {0x364a,0x1b,0}, {0x3500,0x0,0}, {0x3501,0x4c,0}, {0x3502,0x0,0}, {0x3503,0x0,0}, {0x3508,0x2,0},
+{0x3509,0x0,0}, // AEC GAIN
+{0x3700,0x24,0}, {0x3701,0xc,0}, {0x3702,0x28,0}, {0x3703,0x19,0}, {0x3704,0x14,0}, {0x3705,0x0,0}, {0x3706,0x38,0}, {0x3707,0x4,0}, {0x3708,0x24,0}, {0x3709,0x40,0}, {0x370a,0x0,0}, {0x370b,0xb8,0}, {0x370c,0x4,0}, {0x3718,0x12,0}, {0x3719,0x31,0}, {0x3712,0x42,0}, {0x3714,0x12,0}, {0x371e,0x19,0}, {0x371f,0x40,0}, {0x3720,0x5,0}, {0x3721,0x5,0}, {0x3724,0x2,0}, {0x3725,0x2,0}, {0x3726,0x6,0}, {0x3728,0x5,0}, {0x3729,0x2,0}, {0x372a,0x3,0}, {0x372b,0x53,0}, {0x372c,0xa3,0}, {0x372d,0x53,0}, {0x372e,0x6,0}, {0x372f,0x10,0}, {0x3730,0x1,0}, {0x3731,0x6,0}, {0x3732,0x14,0}, {0x3733,0x10,0}, {0x3734,0x40,0}, {0x3736,0x20,0}, {0x373a,0x2,0}, {0x373b,0xc,0}, {0x373c,0xa,0}, {0x373e,0x3,0}, {0x3755,0x40,0}, {0x3758,0x0,0}, {0x3759,0x4c,0}, {0x375a,0x6,0}, {0x375b,0x13,0}, {0x375c,0x40,0}, {0x375d,0x2,0}, {0x375e,0x0,0}, {0x375f,0x14,0}, {0x3767,0x1c,0}, {0x3768,0x4,0}, {0x3769,0x20,0}, {0x376c,0xc0,0}, {0x376d,0xc0,0}, {0x376a,0x8,0}, {0x3761,0x0,0}, {0x3762,0x0,0}, {0x3763,0x0,0}, {0x3766,0xff,0}, {0x376b,0x42,0}, {0x3772,0x23,0}, {0x3773,0x2,0}, {0x3774,0x16,0}, {0x3775,0x12,0}, {0x3776,0x8,0}, {0x37a0,0x44,0}, {0x37a1,0x3d,0}, {0x37a2,0x3d,0}, {0x37a3,0x1,0}, {0x37a4,0x0,0}, {0x37a5,0x8,0}, {0x37a6,0x0,0}, {0x37a7,0x44,0}, {0x37a8,0x58,0}, {0x37a9,0x58,0}, {0x3760,0x0,0}, {0x376f,0x1,0}, {0x37aa,0x44,0}, {0x37ab,0x2e,0}, {0x37ac,0x2e,0}, {0x37ad,0x33,0}, {0x37ae,0xd,0}, {0x37af,0xd,0}, {0x37b0,0x0,0}, {0x37b1,0x0,0}, {0x37b2,0x0,0}, {0x37b3,0x42,0}, {0x37b4,0x42,0}, {0x37b5,0x33,0}, {0x37b6,0x0,0}, {0x37b7,0x0,0}, {0x37b8,0x0,0}, {0x37b9,0xff,0}, {0x3800,0x0,0}, {0x3801,0xc,0}, {0x3802,0x0,0}, {0x3803,0xc,0},
+{0x3804,0xc,0}, {0x3805,0xd3,0}, // 3283
+{0x3806,0x9,0}, {0x3807,0xa3,0}, // 2467
+{0x3808,0x6,0}, {0x3809,0x60,0}, // 0x660 = 1632 (width)
+{0x380a,0x4,0}, {0x380b,0xc8,0}, // 0x4c8 = 1224 (height)
+{0x380c,0x7,0}, {0x380d,0x83,0}, // 0x783 = 1923 (stride)
+{0x380e,0x4,0}, {0x380f,0xe0,0}, // 0x4e0 = 1248 (vstride)
+{0x3810,0x0,0}, {0x3811,0x4,0}, {0x3813,0x4,0},
+{0x3814,0x3,0}, {0x3815,0x1,0}, // H-binning
+{0x3820,0x6,0}, // format1
+{0x3821,0x40,0}, // format2
+{0x382a,0x3,0}, {0x382b,0x1,0}, // V-binning
+{0x382d,0x7f,0}, {0x3830,0x8,0}, {0x3836,0x2,0}, {0x3837,0x18,0},
+{0x3841,0xff,0},
+{0x3846,0x88,0}, {0x3d85,0x6,0}, {0x3d8c,0x75,0}, {0x3d8d,0xef,0}, {0x3f08,0xb,0}, {0x4000,0xf1,0}, {0x4001,0x14,0}, {0x4005,0x10,0}, {0x4006,0x1,0}, {0x4007,0x1,0}, {0x400b,0xc,0}, {0x400d,0x10,0}, {0x401b,0x0,0}, {0x401d,0x0,0}, {0x4020,0x0,0}, {0x4021,0x0,0}, {0x4022,0x4,0}, {0x4023,0x1f,0}, {0x4024,0x6,0}, {0x4025,0x20,0}, {0x4026,0x6,0}, {0x4027,0x4f,0}, {0x4028,0x0,0}, {0x4029,0x2,0}, {0x402a,0x4,0}, {0x402b,0x4,0}, {0x402c,0x2,0}, {0x402d,0x2,0}, {0x402e,0x8,0}, {0x402f,0x2,0}, {0x401f,0x0,0}, {0x4034,0x3f,0}, {0x4300,0xff,0}, {0x4301,0x0,0}, {0x4302,0xf,0}, {0x4500,0x40,0}, {0x4503,0x10,0}, {0x4601,0x74,0}, {0x481f,0x32,0}, {0x4837,0x15,0}, {0x4850,0x10,0}, {0x4851,0x32,0}, {0x4b00,0x2a,0}, {0x4b0d,0x0,0}, {0x4d00,0x4,0}, {0x4d01,0x18,0}, {0x4d02,0xc3,0}, {0x4d03,0xff,0}, {0x4d04,0xff,0}, {0x4d05,0xff,0}, {0x5000,0x96,0}, {0x5001,0x1,0}, {0x5002,0x8,0}, {0x5901,0x0,0},
+{0x5e00,0x0,0},
+//{0x5e00,0x80,0},
+{0x5e01,0x41,0}, {0x5b00,0x2,0}, {0x5b01,0xd0,0}, {0x5b02,0x3,0}, {0x5b03,0xff,0}, {0x5b05,0x6c,0}, {0x5780,0xfc,0}, {0x5781,0xdf,0}, {0x5782,0x3f,0}, {0x5783,0x8,0}, {0x5784,0xc,0}, {0x5786,0x20,0}, {0x5787,0x40,0}, {0x5788,0x8,0}, {0x5789,0x8,0}, {0x578a,0x2,0}, {0x578b,0x1,0}, {0x578c,0x1,0}, {0x578d,0xc,0}, {0x578e,0x2,0}, {0x578f,0x1,0}, {0x5790,0x1,0}, {0x5800,0x1d,0}, {0x5801,0xe,0}, {0x5802,0xc,0}, {0x5803,0xc,0}, {0x5804,0xf,0}, {0x5805,0x22,0}, {0x5806,0xa,0}, {0x5807,0x6,0}, {0x5808,0x5,0}, {0x5809,0x5,0}, {0x580a,0x7,0}, {0x580b,0xa,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x3,0}, {0x5811,0x7,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x3,0}, {0x5817,0x7,0}, {0x5818,0x9,0}, {0x5819,0x6,0}, {0x581a,0x4,0}, {0x581b,0x4,0}, {0x581c,0x6,0}, {0x581d,0xa,0}, {0x581e,0x19,0}, {0x581f,0xd,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xe,0}, {0x5823,0x22,0}, {0x5824,0x23,0}, {0x5825,0x28,0}, {0x5826,0x29,0}, {0x5827,0x27,0}, {0x5828,0x13,0}, {0x5829,0x26,0}, {0x582a,0x33,0}, {0x582b,0x32,0}, {0x582c,0x33,0}, {0x582d,0x16,0}, {0x582e,0x14,0}, {0x582f,0x30,0}, {0x5830,0x31,0}, {0x5831,0x30,0}, {0x5832,0x15,0}, {0x5833,0x26,0}, {0x5834,0x23,0}, {0x5835,0x21,0}, {0x5836,0x23,0}, {0x5837,0x5,0}, {0x5838,0x36,0}, {0x5839,0x27,0}, {0x583a,0x28,0}, {0x583b,0x26,0}, {0x583c,0x24,0}, {0x583d,0xdf,0},
+//{0x100,0x1,0},
+// round 2 (color calibration)
+{0x7010,0x0,0}, {0x7011,0x0,0}, {0x7012,0x0,0}, {0x7013,0x0,0}, {0x7014,0x0,0}, {0x7015,0x0,0}, {0x7016,0x0,0}, {0x7017,0x0,0}, {0x7018,0x0,0}, {0x7019,0x0,0}, {0x701a,0x0,0}, {0x701b,0x0,0}, {0x701c,0x0,0}, {0x701d,0x0,0}, {0x701e,0x0,0}, {0x701f,0x0,0}, {0x7020,0x0,0}, {0x7021,0x0,0}, {0x7022,0x0,0}, {0x7023,0x0,0}, {0x7024,0x0,0}, {0x7025,0x0,0}, {0x7026,0x0,0}, {0x7027,0x0,0}, {0x7028,0x0,0}, {0x7029,0x0,0}, {0x702a,0x0,0}, {0x702b,0x0,0}, {0x702c,0x0,0}, {0x702d,0x0,0}, {0x702e,0x0,0}, {0x702f,0x0,0}, {0x7030,0x0,0}, {0x7031,0x0,0}, {0x7032,0x0,0}, {0x7033,0x0,0}, {0x7034,0x0,0}, {0x7035,0x0,0}, {0x7036,0x0,0}, {0x7037,0x0,0}, {0x7038,0x0,0}, {0x7039,0x0,0}, {0x703a,0x0,0}, {0x703b,0x0,0}, {0x703c,0x0,0}, {0x703d,0x0,0}, {0x703e,0x0,0}, {0x703f,0x0,0}, {0x7040,0x0,0}, {0x7041,0x0,0}, {0x7042,0x0,0}, {0x7043,0x0,0}, {0x7044,0x0,0}, {0x7045,0x0,0}, {0x7046,0x0,0}, {0x7047,0x0,0}, {0x7048,0x0,0}, {0x7049,0x0,0}, {0x704a,0x0,0}, {0x704b,0x0,0}, {0x704c,0x0,0}, {0x704d,0x0,0}, {0x704e,0x0,0}, {0x704f,0x0,0}, {0x7050,0x0,0}, {0x7051,0x0,0}, {0x7052,0x0,0}, {0x7053,0x0,0}, {0x7054,0x0,0}, {0x7055,0x0,0}, {0x7056,0x0,0}, {0x7057,0x0,0}, {0x7058,0x0,0}, {0x7059,0x0,0}, {0x705a,0x0,0}, {0x705b,0x0,0}, {0x705c,0x0,0}, {0x705d,0x0,0}, {0x705e,0x0,0}, {0x705f,0x0,0}, {0x7060,0x0,0}, {0x7061,0x0,0}, {0x7062,0x0,0}, {0x7063,0x0,0}, {0x7064,0x0,0}, {0x7065,0x0,0}, {0x7066,0x0,0}, {0x7067,0x0,0}, {0x7068,0x0,0}, {0x7069,0x0,0}, {0x706a,0x0,0}, {0x706b,0x0,0}, {0x706c,0x0,0}, {0x706d,0x0,0}, {0x706e,0x0,0}, {0x706f,0x0,0}, {0x7070,0x0,0}, {0x7071,0x0,0}, {0x7072,0x0,0}, {0x7073,0x0,0}, {0x7074,0x0,0}, {0x7075,0x0,0}, {0x7076,0x0,0}, {0x7077,0x0,0}, {0x7078,0x0,0}, {0x7079,0x0,0}, {0x707a,0x0,0}, {0x707b,0x0,0}, {0x707c,0x0,0}, {0x707d,0x0,0}, {0x707e,0x0,0}, {0x707f,0x0,0}, {0x7080,0x0,0}, {0x7081,0x0,0}, {0x7082,0x0,0}, {0x7083,0x0,0}, {0x7084,0x0,0}, {0x7085,0x0,0}, {0x7086,0x0,0}, {0x7087,0x0,0}, {0x7088,0x0,0}, {0x7089,0x0,0}, {0x708a,0x0,0}, {0x708b,0x0,0}, {0x708c,0x0,0}, {0x708d,0x0,0}, {0x708e,0x0,0}, {0x708f,0x0,0}, {0x7090,0x0,0}, {0x7091,0x0,0}, {0x7092,0x0,0}, {0x7093,0x0,0}, {0x7094,0x0,0}, {0x7095,0x0,0}, {0x7096,0x0,0}, {0x7097,0x0,0}, {0x7098,0x0,0}, {0x7099,0x0,0}, {0x709a,0x0,0}, {0x709b,0x0,0}, {0x709c,0x0,0}, {0x709d,0x0,0}, {0x709e,0x0,0}, {0x709f,0x0,0}, {0x70a0,0x0,0}, {0x70a1,0x0,0}, {0x70a2,0x0,0}, {0x70a3,0x0,0}, {0x70a4,0x0,0}, {0x70a5,0x0,0}, {0x70a6,0x0,0}, {0x70a7,0x0,0}, {0x70a8,0x0,0}, {0x70a9,0x0,0}, {0x70aa,0x0,0}, {0x70ab,0x0,0}, {0x70ac,0x0,0}, {0x70ad,0x0,0}, {0x70ae,0x0,0}, {0x70af,0x0,0}, {0x70b0,0x0,0}, {0x70b1,0x0,0}, {0x70b2,0x0,0}, {0x70b3,0x0,0}, {0x70b4,0x0,0}, {0x70b5,0x0,0}, {0x70b6,0x0,0}, {0x70b7,0x0,0}, {0x70b8,0x0,0}, {0x70b9,0x0,0}, {0x70ba,0x0,0}, {0x70bb,0x0,0}, {0x70bc,0x0,0}, {0x70bd,0x0,0}, {0x70be,0x0,0}, {0x70bf,0x0,0}, {0x70c0,0x0,0}, {0x70c1,0x0,0}, {0x70c2,0x0,0}, {0x70c3,0x0,0}, {0x70c4,0x0,0}, {0x70c5,0x0,0}, {0x70c6,0x0,0}, {0x70c7,0x0,0}, {0x70c8,0x0,0}, {0x70c9,0x0,0}, {0x70ca,0x0,0}, {0x70cb,0x0,0}, {0x70cc,0x0,0}, {0x70cd,0x0,0}, {0x70ce,0x0,0}, {0x70cf,0x0,0}, {0x70d0,0x0,0}, {0x70d1,0x0,0}, {0x70d2,0x0,0}, {0x70d3,0x0,0}, {0x70d4,0x0,0}, {0x70d5,0x0,0}, {0x70d6,0x0,0}, {0x70d7,0x0,0}, {0x70d8,0x0,0}, {0x70d9,0x0,0}, {0x70da,0x0,0}, {0x70db,0x0,0}, {0x70dc,0x0,0}, {0x70dd,0x0,0}, {0x70de,0x0,0}, {0x70df,0x0,0}, {0x70e0,0x0,0}, {0x70e1,0x0,0}, {0x70e2,0x0,0}, {0x70e3,0x0,0}, {0x70e4,0x0,0}, {0x70e5,0x0,0}, {0x70e6,0x0,0}, {0x70e7,0x0,0}, {0x70e8,0x0,0}, {0x70e9,0x0,0}, {0x70ea,0x0,0}, {0x70eb,0x0,0}, {0x70ec,0x0,0}, {0x70ed,0x0,0}, {0x70ee,0x0,0}, {0x70ef,0x0,0}, {0x70f0,0x0,0}, {0x70f1,0x0,0}, {0x70f2,0x0,0}, {0x70f3,0x0,0}, {0x70f4,0x0,0}, {0x70f5,0x0,0}, {0x70f6,0x0,0}, {0x70f7,0x0,0}, {0x70f8,0x0,0}, {0x70f9,0x0,0}, {0x70fa,0x0,0}, {0x70fb,0x0,0}, {0x70fc,0x0,0}, {0x70fd,0x0,0}, {0x70fe,0x0,0}, {0x70ff,0x0,0}, {0x7100,0x0,0}, {0x7101,0x0,0}, {0x7102,0x0,0}, {0x7103,0x0,0}, {0x7104,0x0,0}, {0x7105,0x0,0}, {0x7106,0x0,0}, {0x7107,0x0,0}, {0x7108,0x0,0}, {0x7109,0x0,0}, {0x710a,0x0,0}, {0x710b,0x0,0}, {0x710c,0x0,0}, {0x710d,0x0,0}, {0x710e,0x0,0}, {0x710f,0x0,0}, {0x7110,0x0,0}, {0x7111,0x0,0}, {0x7112,0x0,0}, {0x7113,0x0,0}, {0x7114,0x0,0}, {0x7115,0x0,0}, {0x7116,0x0,0}, {0x7117,0x0,0}, {0x7118,0x0,0}, {0x7119,0x0,0}, {0x711a,0x0,0}, {0x711b,0x0,0}, {0x711c,0x0,0}, {0x711d,0x0,0}, {0x711e,0x0,0}, {0x711f,0x0,0}, {0x7120,0x0,0}, {0x7121,0x0,0}, {0x7122,0x0,0}, {0x7123,0x0,0}, {0x7124,0x0,0}, {0x7125,0x0,0}, {0x7126,0x0,0}, {0x7127,0x0,0}, {0x7128,0x0,0}, {0x7129,0x0,0}, {0x712a,0x0,0}, {0x712b,0x0,0}, {0x712c,0x0,0}, {0x712d,0x0,0}, {0x712e,0x0,0}, {0x712f,0x0,0}, {0x7130,0x0,0}, {0x7131,0x0,0}, {0x7132,0x0,0}, {0x501a,0x10,0}, {0x501b,0xd,0}, {0x501c,0x10,0}, {0x501d,0x13,0}, {0x5000,0x96,0}, {0x5800,0x14,0}, {0x5801,0xd,0}, {0x5802,0xa,0}, {0x5803,0xa,0}, {0x5804,0xd,0}, {0x5805,0x13,0}, {0x5806,0xa,0}, {0x5807,0x5,0}, {0x5808,0x3,0}, {0x5809,0x3,0}, {0x580a,0x5,0}, {0x580b,0x9,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x2,0}, {0x5811,0x5,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x2,0}, {0x5817,0x5,0}, {0x5818,0xb,0}, {0x5819,0x6,0}, {0x581a,0x3,0}, {0x581b,0x3,0}, {0x581c,0x5,0}, {0x581d,0xa,0}, {0x581e,0x16,0}, {0x581f,0xf,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xf,0}, {0x5823,0x15,0}, {0x5824,0x32,0}, {0x5825,0x23,0}, {0x5826,0x23,0}, {0x5827,0x23,0}, {0x5828,0x22,0}, {0x5829,0x21,0}, {0x582a,0x21,0}, {0x582b,0x22,0}, {0x582c,0x21,0},{0x582d,0x11,0}, {0x582e,0x22,0}, {0x582f,0x31,0}, {0x5830,0x41,0}, {0x5831,0x31,0}, {0x5832,0x1,0}, {0x5833,0x21,0}, {0x5834,0x21,0}, {0x5835,0x21,0}, {0x5836,0x11,0}, {0x5837,0x11,0}, {0x5838,0x22,0}, {0x5839,0x22,0}, {0x583a,0x12,0}, {0x583b,0x22,0}, {0x583c,0x22,0}, {0x583d,0xdf,0},
+};
+
diff --git a/selfdrive/visiond/snpemodel.cc b/selfdrive/visiond/snpemodel.cc
new file mode 100644
index 00000000000000..ae7b7f10a1531e
--- /dev/null
+++ b/selfdrive/visiond/snpemodel.cc
@@ -0,0 +1,94 @@
+#include "snpemodel.h"
+
+void PrintErrorStringAndExit() {
+ const char* const errStr = zdl::DlSystem::getLastErrorString();
+ std::cerr << zdl::DlSystem::getLastErrorString() << std::endl;
+ std::exit(EXIT_FAILURE);
+}
+
+SNPEModel::SNPEModel(const uint8_t *model_data, const size_t model_size, float *output, size_t output_size) {
+ assert(zdl::SNPE::SNPEFactory::isRuntimeAvailable(zdl::DlSystem::Runtime_t::GPU));
+
+ // load model
+ std::unique_ptr container = zdl::DlContainer::IDlContainer::open(model_data, model_size);
+ if (!container) { PrintErrorStringAndExit(); }
+ printf("loaded model with size: %d\n", model_size);
+
+ // create model runner
+ zdl::SNPE::SNPEBuilder snpeBuilder(container.get());
+ while (!snpe) {
+ snpe = snpeBuilder.setOutputLayers({})
+ .setRuntimeProcessor(zdl::DlSystem::Runtime_t::GPU)
+ .setUseUserSuppliedBuffers(true)
+ .setPerformanceProfile(zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE)
+ .build();
+ if (!snpe) std::cerr << zdl::DlSystem::getLastErrorString() << std::endl;
+ }
+
+ // get input and output names
+ const auto &strListi_opt = snpe->getInputTensorNames();
+ if (!strListi_opt) throw std::runtime_error("Error obtaining Input tensor names");
+ const auto &strListi = *strListi_opt;
+ //assert(strListi.size() == 1);
+ const char *input_tensor_name = strListi.at(0);
+
+ const auto &strListo_opt = snpe->getOutputTensorNames();
+ if (!strListo_opt) throw std::runtime_error("Error obtaining Output tensor names");
+ const auto &strListo = *strListo_opt;
+ assert(strListo.size() == 1);
+ const char *output_tensor_name = strListo.at(0);
+
+ printf("model: %s -> %s\n", input_tensor_name, output_tensor_name);
+
+ zdl::DlSystem::UserBufferEncodingFloat userBufferEncodingFloat;
+ zdl::DlSystem::IUserBufferFactory& ubFactory = zdl::SNPE::SNPEFactory::getUserBufferFactory();
+
+ // create input buffer
+ {
+ const auto &inputDims_opt = snpe->getInputDimensions(input_tensor_name);
+ const zdl::DlSystem::TensorShape& bufferShape = *inputDims_opt;
+ std::vector strides(bufferShape.rank());
+ strides[strides.size() - 1] = sizeof(float);
+ size_t product = 1;
+ for (size_t i = 0; i < bufferShape.rank(); i++) product *= bufferShape[i];
+ size_t stride = strides[strides.size() - 1];
+ for (size_t i = bufferShape.rank() - 1; i > 0; i--) {
+ stride *= bufferShape[i];
+ strides[i-1] = stride;
+ }
+ printf("input product is %u\n", product);
+ inputBuffer = ubFactory.createUserBuffer(NULL, product*sizeof(float), strides, &userBufferEncodingFloat);
+
+ inputMap.add(input_tensor_name, inputBuffer.get());
+ }
+
+ // create output buffer
+ {
+ std::vector outputStrides = {output_size * sizeof(float), sizeof(float)};
+ outputBuffer = ubFactory.createUserBuffer(output, output_size * sizeof(float), outputStrides, &userBufferEncodingFloat);
+ outputMap.add(output_tensor_name, outputBuffer.get());
+ }
+}
+
+void SNPEModel::addRecurrent(float *state, int state_size) {
+ // get input and output names
+ const auto &strListi_opt = snpe->getInputTensorNames();
+ if (!strListi_opt) throw std::runtime_error("Error obtaining Input tensor names");
+ const auto &strListi = *strListi_opt;
+ const char *input_tensor_name = strListi.at(1);
+ printf("adding recurrent: %s\n", input_tensor_name);
+
+ zdl::DlSystem::UserBufferEncodingFloat userBufferEncodingFloat;
+ zdl::DlSystem::IUserBufferFactory& ubFactory = zdl::SNPE::SNPEFactory::getUserBufferFactory();
+ std::vector recurrentStrides = {state_size * sizeof(float), sizeof(float)};
+ recurrentBuffer = ubFactory.createUserBuffer(state, state_size * sizeof(float), recurrentStrides, &userBufferEncodingFloat);
+ inputMap.add(input_tensor_name, recurrentBuffer.get());
+}
+
+void SNPEModel::execute(float *net_input_buf) {
+ assert(inputBuffer->setBufferAddress(net_input_buf));
+ if (!snpe->execute(inputMap, outputMap)) {
+ PrintErrorStringAndExit();
+ }
+}
+
diff --git a/selfdrive/visiond/snpemodel.h b/selfdrive/visiond/snpemodel.h
new file mode 100644
index 00000000000000..a7fc6083db3541
--- /dev/null
+++ b/selfdrive/visiond/snpemodel.h
@@ -0,0 +1,37 @@
+#ifndef SNPEMODEL_H
+#define SNPEMODEL_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+class SNPEModel {
+public:
+ SNPEModel(const uint8_t *model_data, const size_t model_size, float *output, size_t output_size);
+ void addRecurrent(float *state, int state_size);
+ void execute(float *net_input_buf);
+private:
+ // snpe model stuff
+ std::unique_ptr snpe;
+
+ // snpe input stuff
+ zdl::DlSystem::UserBufferMap inputMap;
+ std::unique_ptr inputBuffer;
+
+ // snpe output stuff
+ zdl::DlSystem::UserBufferMap outputMap;
+ std::unique_ptr outputBuffer;
+ float *output;
+
+ // recurrent
+ std::unique_ptr recurrentBuffer;
+};
+
+#endif
+
diff --git a/selfdrive/visiond/transform.c b/selfdrive/visiond/transform.c
new file mode 100644
index 00000000000000..5f3d7ad5a11c95
--- /dev/null
+++ b/selfdrive/visiond/transform.c
@@ -0,0 +1,149 @@
+#include
+#include
+
+#include "clutil.h"
+
+#include "transform.h"
+
+void transform_init(Transform* s, cl_context ctx, cl_device_id device_id) {
+ int err = 0;
+ memset(s, 0, sizeof(*s));
+
+ cl_program prg = CLU_LOAD_FROM_FILE(ctx, device_id, "transform.cl", "");
+
+ s->krnl = clCreateKernel(prg, "warpPerspective", &err);
+ assert(err == 0);
+
+ // done with this
+ err = clReleaseProgram(prg);
+ assert(err == 0);
+
+ s->m_y_cl = clCreateBuffer(ctx, CL_MEM_READ_WRITE, 3*3*sizeof(float), NULL, &err);
+ assert(err == 0);
+
+ s->m_uv_cl = clCreateBuffer(ctx, CL_MEM_READ_WRITE, 3*3*sizeof(float), NULL, &err);
+ assert(err == 0);
+}
+
+void transform_destroy(Transform* s) {
+ int err = 0;
+
+ err = clReleaseMemObject(s->m_y_cl);
+ assert(err == 0);
+ err = clReleaseMemObject(s->m_uv_cl);
+ assert(err == 0);
+
+ err = clReleaseKernel(s->krnl);
+ assert(err == 0);
+}
+
+void transform_queue(Transform* s,
+ cl_command_queue q,
+ cl_mem in_yuv, int in_width, int in_height,
+ cl_mem out_y, cl_mem out_u, cl_mem out_v,
+ int out_width, int out_height,
+ mat3 projection) {
+ int err = 0;
+ const int zero = 0;
+
+ // sampled using pixel center origin
+ // (because thats how fastcv and opencv does it)
+
+ mat3 projection_y = projection;
+
+ // in and out uv is half the size of y.
+ mat3 projection_uv = transform_scale_buffer(projection, 0.5);
+
+ err = clEnqueueWriteBuffer(q, s->m_y_cl, CL_TRUE, 0, 3*3*sizeof(float), (void*)projection_y.v, 0, NULL, NULL);
+ assert(err == 0);
+ err = clEnqueueWriteBuffer(q, s->m_uv_cl, CL_TRUE, 0, 3*3*sizeof(float), (void*)projection_uv.v, 0, NULL, NULL);
+ assert(err == 0);
+
+ const int in_y_width = in_width;
+ const int in_y_height = in_height;
+ const int in_uv_width = in_width/2;
+ const int in_uv_height = in_height/2;
+ const int in_y_offset = 0;
+ const int in_u_offset = in_y_offset + in_y_width*in_y_height;
+ const int in_v_offset = in_u_offset + in_uv_width*in_uv_height;
+
+ const int out_y_width = out_width;
+ const int out_y_height = out_height;
+ const int out_uv_width = out_width/2;
+ const int out_uv_height = out_height/2;
+
+ err = clSetKernelArg(s->krnl, 0, sizeof(cl_mem), &in_yuv);
+ assert(err == 0);
+
+ err = clSetKernelArg(s->krnl, 1, sizeof(cl_int), &in_y_width);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_y_offset);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_y_height);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_y_width);
+ assert(err == 0);
+
+ err = clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_y);
+ assert(err == 0);
+
+ err = clSetKernelArg(s->krnl, 6, sizeof(cl_int), &out_y_width);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 7, sizeof(cl_int), &zero);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 8, sizeof(cl_int), &out_y_height);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_y_width);
+ assert(err == 0);
+
+ err = clSetKernelArg(s->krnl, 10, sizeof(cl_mem), &s->m_y_cl);
+ assert(err == 0);
+
+ const size_t work_size_y[2] = {out_y_width, out_y_height};
+
+ err = clEnqueueNDRangeKernel(q, s->krnl, 2, NULL,
+ (const size_t*)&work_size_y, NULL, 0, 0, NULL);
+ assert(err == 0);
+
+
+ const size_t work_size_uv[2] = {out_uv_width, out_uv_height};
+
+ err = clSetKernelArg(s->krnl, 1, sizeof(cl_int), &in_uv_width);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_u_offset);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_uv_height);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_uv_width);
+ assert(err == 0);
+
+ err = clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_u);
+ assert(err == 0);
+
+ err = clSetKernelArg(s->krnl, 6, sizeof(cl_int), &out_uv_width);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 7, sizeof(cl_int), &zero);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 8, sizeof(cl_int), &out_uv_height);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_uv_width);
+ assert(err == 0);
+
+ err = clSetKernelArg(s->krnl, 10, sizeof(cl_mem), &s->m_uv_cl);
+ assert(err == 0);
+
+ err = clEnqueueNDRangeKernel(q, s->krnl, 2, NULL,
+ (const size_t*)&work_size_uv, NULL, 0, 0, NULL);
+ assert(err == 0);
+
+
+ err = clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_v_offset);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_v);
+ assert(err == 0);
+
+
+ err = clEnqueueNDRangeKernel(q, s->krnl, 2, NULL,
+ (const size_t*)&work_size_uv, NULL, 0, 0, NULL);
+ assert(err == 0);
+}
diff --git a/selfdrive/visiond/transform.cl b/selfdrive/visiond/transform.cl
new file mode 100644
index 00000000000000..8ad186935114c9
--- /dev/null
+++ b/selfdrive/visiond/transform.cl
@@ -0,0 +1,54 @@
+#define INTER_BITS 5
+#define INTER_TAB_SIZE (1 << INTER_BITS)
+#define INTER_SCALE 1.f / INTER_TAB_SIZE
+
+#define INTER_REMAP_COEF_BITS 15
+#define INTER_REMAP_COEF_SCALE (1 << INTER_REMAP_COEF_BITS)
+
+__kernel void warpPerspective(__global const uchar * src,
+ int src_step, int src_offset, int src_rows, int src_cols,
+ __global uchar * dst,
+ int dst_step, int dst_offset, int dst_rows, int dst_cols,
+ __constant float * M)
+{
+ int dx = get_global_id(0);
+ int dy = get_global_id(1);
+
+ if (dx < dst_cols && dy < dst_rows)
+ {
+ float X0 = M[0] * dx + M[1] * dy + M[2];
+ float Y0 = M[3] * dx + M[4] * dy + M[5];
+ float W = M[6] * dx + M[7] * dy + M[8];
+ W = W != 0.0f ? INTER_TAB_SIZE / W : 0.0f;
+ int X = rint(X0 * W), Y = rint(Y0 * W);
+
+ short sx = convert_short_sat(X >> INTER_BITS);
+ short sy = convert_short_sat(Y >> INTER_BITS);
+ short ay = (short)(Y & (INTER_TAB_SIZE - 1));
+ short ax = (short)(X & (INTER_TAB_SIZE - 1));
+
+ int v0 = (sx >= 0 && sx < src_cols && sy >= 0 && sy < src_rows) ?
+ convert_int(src[mad24(sy, src_step, src_offset + sx)]) : 0;
+ int v1 = (sx+1 >= 0 && sx+1 < src_cols && sy >= 0 && sy < src_rows) ?
+ convert_int(src[mad24(sy, src_step, src_offset + (sx+1))]) : 0;
+ int v2 = (sx >= 0 && sx < src_cols && sy+1 >= 0 && sy+1 < src_rows) ?
+ convert_int(src[mad24(sy+1, src_step, src_offset + sx)]) : 0;
+ int v3 = (sx+1 >= 0 && sx+1 < src_cols && sy+1 >= 0 && sy+1 < src_rows) ?
+ convert_int(src[mad24(sy+1, src_step, src_offset + (sx+1))]) : 0;
+
+ float taby = 1.f/INTER_TAB_SIZE*ay;
+ float tabx = 1.f/INTER_TAB_SIZE*ax;
+
+ int dst_index = mad24(dy, dst_step, dst_offset + dx);
+
+ int itab0 = convert_short_sat_rte( (1.0f-taby)*(1.0f-tabx) * INTER_REMAP_COEF_SCALE );
+ int itab1 = convert_short_sat_rte( (1.0f-taby)*tabx * INTER_REMAP_COEF_SCALE );
+ int itab2 = convert_short_sat_rte( taby*(1.0f-tabx) * INTER_REMAP_COEF_SCALE );
+ int itab3 = convert_short_sat_rte( taby*tabx * INTER_REMAP_COEF_SCALE );
+
+ int val = v0 * itab0 + v1 * itab1 + v2 * itab2 + v3 * itab3;
+
+ uchar pix = convert_uchar_sat((val + (1 << (INTER_REMAP_COEF_BITS-1))) >> INTER_REMAP_COEF_BITS);
+ dst[dst_index] = pix;
+ }
+}
diff --git a/selfdrive/visiond/transform.h b/selfdrive/visiond/transform.h
new file mode 100644
index 00000000000000..3854be9da62db6
--- /dev/null
+++ b/selfdrive/visiond/transform.h
@@ -0,0 +1,38 @@
+#ifndef TRANSFORM_H
+#define TRANSFORM_H
+
+#include
+#include
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#include "common/mat.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ cl_kernel krnl;
+ cl_mem m_y_cl, m_uv_cl;
+} Transform;
+
+void transform_init(Transform* s, cl_context ctx, cl_device_id device_id);
+
+void transform_destroy(Transform* transform);
+
+void transform_queue(Transform* s, cl_command_queue q,
+ cl_mem yuv, int in_width, int in_height,
+ cl_mem out_y, cl_mem out_u, cl_mem out_v,
+ int out_width, int out_height,
+ mat3 projection);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TRANSFORM_H
diff --git a/selfdrive/visiond/visiond b/selfdrive/visiond/visiond
deleted file mode 100755
index fe893d1e6d76da..00000000000000
--- a/selfdrive/visiond/visiond
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:016532ef568e316d01be47439b1840b52001080796ef614811c65e92e5588a98
-size 8844456
diff --git a/selfdrive/visiond/visiond.cc b/selfdrive/visiond/visiond.cc
new file mode 100644
index 00000000000000..a64eaa054c1965
--- /dev/null
+++ b/selfdrive/visiond/visiond.cc
@@ -0,0 +1,1340 @@
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#include
+#include
+#include
+
+#include "common/version.h"
+#include "common/util.h"
+#include "common/timing.h"
+#include "common/mat.h"
+#include "common/swaglog.h"
+#include "common/visionipc.h"
+#include "common/visionbuf.h"
+#include "common/visionimg.h"
+#include "common/buffering.h"
+
+#include "clutil.h"
+#include "bufs.h"
+
+#ifdef QCOM
+#include "camera_qcom.h"
+#else
+#include "camera_fake.h"
+#endif
+
+#include "model.h"
+#include "monitoring.h"
+
+#include "cereal/gen/cpp/log.capnp.h"
+
+#define UI_BUF_COUNT 4
+
+//#define DUMP_RGB
+
+//#define DEBUG_DRIVER_MONITOR
+
+// send net input on port 9000
+//#define SEND_NET_INPUT
+
+#define YUV_COUNT 40
+#define MAX_CLIENTS 5
+
+#ifdef __APPLE__
+typedef void (*sighandler_t) (int);
+#endif
+
+extern "C" {
+volatile int do_exit = 0;
+}
+
+namespace {
+
+struct VisionState;
+
+struct VisionClientState {
+ VisionState *s;
+ int fd;
+ pthread_t thread_handle;
+ bool running;
+};
+
+struct VisionClientStreamState {
+ bool subscribed;
+ int bufs_outstanding;
+ bool tb;
+ TBuffer* tbuffer;
+ PoolQueue* queue;
+};
+
+struct VisionState {
+
+ int frame_width, frame_height;
+ int frame_stride;
+ int frame_size;
+
+ int ion_fd;
+
+ // cl state
+ cl_device_id device_id;
+ cl_context context;
+
+ cl_program prg_debayer_rear;
+ cl_program prg_debayer_front;
+ cl_kernel krnl_debayer_rear;
+ cl_kernel krnl_debayer_front;
+
+ // processing
+ TBuffer ui_tb;
+ TBuffer ui_front_tb;
+
+ mat3 yuv_transform;
+ TBuffer *yuv_tb;
+
+ // TODO: refactor for both cameras?
+ Pool yuv_pool;
+ VisionBuf yuv_ion[YUV_COUNT];
+ cl_mem yuv_cl[YUV_COUNT];
+ YUVBuf yuv_bufs[YUV_COUNT];
+ FrameMetadata yuv_metas[YUV_COUNT];
+ size_t yuv_buf_size;
+ int yuv_width, yuv_height;
+
+ // for front camera recording
+ Pool yuv_front_pool;
+ VisionBuf yuv_front_ion[YUV_COUNT];
+ cl_mem yuv_front_cl[YUV_COUNT];
+ YUVBuf yuv_front_bufs[YUV_COUNT];
+ FrameMetadata yuv_front_metas[YUV_COUNT];
+ size_t yuv_front_buf_size;
+ int yuv_front_width, yuv_front_height;
+
+ size_t rgb_buf_size;
+ int rgb_width, rgb_height, rgb_stride;
+ VisionBuf rgb_bufs[UI_BUF_COUNT];
+ cl_mem rgb_bufs_cl[UI_BUF_COUNT];
+
+ size_t rgb_front_buf_size;
+ int rgb_front_width, rgb_front_height, rgb_front_stride;
+ VisionBuf rgb_front_bufs[UI_BUF_COUNT];
+ cl_mem rgb_front_bufs_cl[UI_BUF_COUNT];
+
+ ModelState model;
+ ModelData model_bufs[UI_BUF_COUNT];
+
+ MonitoringState monitoring;
+ zsock_t *monitoring_sock;
+ void* monitoring_sock_raw;
+
+ // Protected by transform_lock.
+ bool run_model;
+ mat3 cur_transform;
+ pthread_mutex_t transform_lock;
+
+ cl_mem camera_bufs_cl[FRAME_BUF_COUNT];
+ VisionBuf camera_bufs[FRAME_BUF_COUNT];
+ VisionBuf focus_bufs[FRAME_BUF_COUNT];
+ VisionBuf stats_bufs[FRAME_BUF_COUNT];
+
+ cl_mem front_camera_bufs_cl[FRAME_BUF_COUNT];
+ VisionBuf front_camera_bufs[FRAME_BUF_COUNT];
+
+ DualCameraState cameras;
+
+ zsock_t *terminate_pub;
+ zsock_t *recorder_sock;
+ void* recorder_sock_raw;
+
+ pthread_mutex_t clients_lock;
+ VisionClientState clients[MAX_CLIENTS];
+
+};
+
+void hexdump(uint8_t *d, int l) {
+ for (int i = 0; i < l; i++) {
+ if (i%0x10 == 0 && i != 0) printf("\n");
+ printf("%02X ", d[i]);
+ }
+ printf("\n");
+}
+
+int mkpath(char* file_path, mode_t mode) {
+ assert(file_path && *file_path);
+ char* p;
+ for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) {
+ *p='\0';
+ if (mkdir(file_path, mode)==-1) {
+ if (errno!=EEXIST) { *p='/'; return -1; }
+ }
+ *p='/';
+ }
+ return 0;
+}
+
+////////// cl stuff
+
+cl_program build_debayer_program(VisionState *s,
+ int frame_width, int frame_height, int frame_stride,
+ int rgb_width, int rgb_height, int rgb_stride,
+ int bayer_flip, int hdr) {
+ assert(rgb_width == frame_width/2);
+ assert(rgb_height == frame_height/2);
+
+ char args[4096];
+ snprintf(args, sizeof(args),
+ "-cl-fast-relaxed-math -cl-denorms-are-zero "
+ "-DFRAME_WIDTH=%d -DFRAME_HEIGHT=%d -DFRAME_STRIDE=%d "
+ "-DRGB_WIDTH=%d -DRGB_HEIGHT=%d -DRGB_STRIDE=%d "
+ "-DBAYER_FLIP=%d -DHDR=%d",
+ frame_width, frame_height, frame_stride,
+ rgb_width, rgb_height, rgb_stride,
+ bayer_flip, hdr);
+ return CLU_LOAD_FROM_FILE(s->context, s->device_id, "debayer.cl", args);
+}
+
+void cl_init(VisionState *s) {
+ int err;
+ cl_platform_id platform_id = NULL;
+ cl_uint num_devices;
+ cl_uint num_platforms;
+
+ err = clGetPlatformIDs(1, &platform_id, &num_platforms);
+ assert(err == 0);
+ err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1,
+ &s->device_id, &num_devices);
+ assert(err == 0);
+
+ cl_print_info(platform_id, s->device_id);
+ printf("\n");
+
+ s->context = clCreateContext(NULL, 1, &s->device_id, NULL, NULL, &err);
+ assert(err == 0);
+}
+
+void cl_free(VisionState *s) {
+ int err;
+
+ err = clReleaseContext(s->context);
+ assert(err == 0);
+}
+
+//////////
+
+#if 0
+// from libadreno_utils.so
+extern "C" void compute_aligned_width_and_height(int width,
+ int height,
+ int bpp,
+ int tile_mode,
+ int raster_mode,
+ int padding_threshold,
+ int *aligned_w,
+ int *aligned_h);
+
+// TODO: move to visionbuf
+void alloc_rgb888_bufs_cl(cl_device_id device_id, cl_context ctx,
+ int width, int height, int count,
+ int *out_stride, size_t *out_size,
+ VisionBuf *out_bufs, cl_mem *out_cl) {
+
+ int aligned_w = 0, aligned_h = 0;
+#ifdef QCOM
+ compute_aligned_width_and_height(ALIGN(width, 32), ALIGN(height, 32), 3, 0, 0, 512, &aligned_w, &aligned_h);
+#else
+ aligned_w = width; aligned_h = height;
+#endif
+
+ int stride = aligned_w * 3;
+ size_t size = aligned_w * aligned_h * 3;
+
+ for (int i=0; icamera_bufs[i] = visionbuf_allocate_cl(s->frame_size, s->device_id, s->context,
+ &s->camera_bufs_cl[i]);
+ // TODO: make lengths correct
+ s->focus_bufs[i] = visionbuf_allocate(0xb80);
+ s->stats_bufs[i] = visionbuf_allocate(0xb80);
+ }
+
+ for (int i=0; ifront_camera_bufs[i] = visionbuf_allocate_cl(s->cameras.front.frame_size,
+ s->device_id, s->context,
+ &s->front_camera_bufs_cl[i]);
+ }
+
+ // processing buffers
+ if (s->cameras.rear.ci.bayer) {
+ s->rgb_width = s->frame_width/2;
+ s->rgb_height = s->frame_height/2;
+ } else {
+ s->rgb_width = s->frame_width;
+ s->rgb_height = s->frame_height;
+ }
+
+ for (int i=0; irgb_width, s->rgb_height, &s->rgb_bufs[i]);
+ s->rgb_bufs_cl[i] = visionbuf_to_cl(&s->rgb_bufs[i], s->device_id, s->context);
+ if (i == 0){
+ s->rgb_stride = img.stride;
+ s->rgb_buf_size = img.size;
+ }
+ }
+ tbuffer_init(&s->ui_tb, UI_BUF_COUNT, "rgb");
+
+ assert(s->cameras.front.ci.bayer);
+ s->rgb_front_width = s->cameras.front.ci.frame_width/2;
+ s->rgb_front_height = s->cameras.front.ci.frame_height/2;
+
+ for (int i=0; irgb_front_width, s->rgb_front_height, &s->rgb_front_bufs[i]);
+ s->rgb_front_bufs_cl[i] = visionbuf_to_cl(&s->rgb_front_bufs[i], s->device_id, s->context);
+ if (i == 0){
+ s->rgb_front_stride = img.stride;
+ s->rgb_front_buf_size = img.size;
+ }
+ }
+ tbuffer_init(&s->ui_front_tb, UI_BUF_COUNT, "frontrgb");
+
+ // yuv back for recording and orbd
+ pool_init(&s->yuv_pool, YUV_COUNT);
+
+ s->yuv_tb = pool_get_tbuffer(&s->yuv_pool); //only for visionserver...
+
+ s->yuv_width = s->rgb_width;
+ s->yuv_height = s->rgb_height;
+ s->yuv_buf_size = s->rgb_width * s->rgb_height * 3 / 2;
+
+ for (int i=0; iyuv_ion[i] = visionbuf_allocate_cl(s->yuv_buf_size, s->device_id, s->context, &s->yuv_cl[i]);
+ s->yuv_bufs[i].y = (uint8_t*)s->yuv_ion[i].addr;
+ s->yuv_bufs[i].u = s->yuv_bufs[i].y + (s->yuv_width * s->yuv_height);
+ s->yuv_bufs[i].v = s->yuv_bufs[i].u + (s->yuv_width/2 * s->yuv_height/2);
+ }
+
+ // yuv front for recording
+ pool_init(&s->yuv_front_pool, YUV_COUNT);
+
+ s->yuv_front_width = s->rgb_front_width;
+ s->yuv_front_height = s->rgb_front_height;
+ s->yuv_front_buf_size = s->rgb_front_width * s->rgb_front_height * 3 / 2;
+
+ for (int i=0; iyuv_front_ion[i] = visionbuf_allocate_cl(s->yuv_front_buf_size, s->device_id, s->context, &s->yuv_front_cl[i]);
+ s->yuv_front_bufs[i].y = (uint8_t*)s->yuv_front_ion[i].addr;
+ s->yuv_front_bufs[i].u = s->yuv_front_bufs[i].y + (s->yuv_front_width * s->yuv_front_height);
+ s->yuv_front_bufs[i].v = s->yuv_front_bufs[i].u + (s->yuv_front_width/2 * s->yuv_front_height/2);
+ }
+
+ if (s->cameras.rear.ci.bayer) {
+ // debayering does a 2x downscale
+ s->yuv_transform = transform_scale_buffer(s->cameras.rear.transform, 0.5);
+ } else {
+ s->yuv_transform = s->cameras.rear.transform;
+ }
+
+ // build all the camera debayer programs
+ for (int i=0; iprg_debayer_rear = build_debayer_program(s, s->cameras.rear.ci.frame_width, s->cameras.rear.ci.frame_height,
+ s->cameras.rear.ci.frame_stride,
+ s->rgb_width, s->rgb_height, s->rgb_stride,
+ s->cameras.rear.ci.bayer_flip, s->cameras.rear.ci.hdr);
+
+ s->prg_debayer_front = build_debayer_program(s, s->cameras.front.ci.frame_width, s->cameras.front.ci.frame_height,
+ s->cameras.front.ci.frame_stride,
+ s->rgb_front_width, s->rgb_front_height, s->rgb_front_stride,
+ s->cameras.front.ci.bayer_flip, s->cameras.front.ci.hdr);
+
+ s->krnl_debayer_rear = clCreateKernel(s->prg_debayer_rear, "debayer10", &err);
+ assert(err == 0);
+ s->krnl_debayer_front = clCreateKernel(s->prg_debayer_front, "debayer10", &err);
+ assert(err == 0);
+}
+
+void free_buffers(VisionState *s) {
+ // free bufs
+ for (int i=0; icamera_bufs[i]);
+ visionbuf_free(&s->focus_bufs[i]);
+ visionbuf_free(&s->stats_bufs[i]);
+ }
+
+ for (int i=0; ifront_camera_bufs[i]);
+ }
+
+ for (int i=0; irgb_bufs[i]);
+ }
+
+ for (int i=0; irgb_front_bufs[i]);
+ }
+
+ for (int i=0; iyuv_ion[i]);
+ }
+}
+
+void* visionserver_client_thread(void* arg) {
+ int err;
+ VisionClientState *client = (VisionClientState*)arg;
+ VisionState *s = client->s;
+ int fd = client->fd;
+
+ set_thread_name("clientthread");
+
+ zsock_t *terminate = zsock_new_sub(">inproc://terminate", "");
+ assert(terminate);
+ void* terminate_raw = zsock_resolve(terminate);
+
+ VisionClientStreamState streams[VISION_STREAM_MAX] = {{0}};
+
+ LOG("client start fd %d\n", fd);
+
+ while (true) {
+ zmq_pollitem_t polls[2+VISION_STREAM_MAX] = {{0}};
+ polls[0].socket = terminate_raw;
+ polls[0].events = ZMQ_POLLIN;
+ polls[1].fd = fd;
+ polls[1].events = ZMQ_POLLIN;
+
+ int poll_to_stream[2+VISION_STREAM_MAX] = {0};
+ int num_polls = 2;
+ for (int i=0; i= 2) {
+ continue;
+ }
+ if (streams[i].tb) {
+ polls[num_polls].fd = tbuffer_efd(streams[i].tbuffer);
+ } else {
+ polls[num_polls].fd = poolq_efd(streams[i].queue);
+ }
+ poll_to_stream[num_polls] = i;
+ num_polls++;
+ }
+ int ret = zmq_poll(polls, num_polls, -1);
+ if (ret < 0) {
+ LOGE("poll failed (%d)", ret);
+ break;
+ }
+ if (polls[0].revents) {
+ break;
+ } else if (polls[1].revents) {
+ VisionPacket p;
+ err = vipc_recv(fd, &p);
+ // printf("recv %d\n", p.type);
+ if (err <= 0) {
+ break;
+ } else if (p.type == VIPC_STREAM_SUBSCRIBE) {
+ VisionStreamType stream_type = p.d.stream_sub.type;
+ VisionPacket rep = {
+ .type = VIPC_STREAM_BUFS,
+ .d = { .stream_bufs = { .type = stream_type }, },
+ };
+
+ VisionClientStreamState *stream = &streams[stream_type];
+ stream->tb = p.d.stream_sub.tbuffer;
+
+ VisionStreamBufs *stream_bufs = &rep.d.stream_bufs;
+ if (stream_type == VISION_STREAM_RGB_BACK) {
+ stream_bufs->width = s->rgb_width;
+ stream_bufs->height = s->rgb_height;
+ stream_bufs->stride = s->rgb_stride;
+ stream_bufs->buf_len = s->rgb_bufs[0].len;
+ rep.num_fds = UI_BUF_COUNT;
+ for (int i=0; irgb_bufs[i].fd;
+ }
+ if (stream->tb) {
+ stream->tbuffer = &s->ui_tb;
+ } else {
+ assert(false);
+ }
+ } else if (stream_type == VISION_STREAM_RGB_FRONT) {
+ stream_bufs->width = s->rgb_front_width;
+ stream_bufs->height = s->rgb_front_height;
+ stream_bufs->stride = s->rgb_front_stride;
+ stream_bufs->buf_len = s->rgb_front_bufs[0].len;
+ rep.num_fds = UI_BUF_COUNT;
+ for (int i=0; irgb_front_bufs[i].fd;
+ }
+ if (stream->tb) {
+ stream->tbuffer = &s->ui_front_tb;
+ } else {
+ assert(false);
+ }
+ } else if (stream_type == VISION_STREAM_YUV) {
+ stream_bufs->width = s->yuv_width;
+ stream_bufs->height = s->yuv_height;
+ stream_bufs->stride = s->yuv_width;
+ stream_bufs->buf_len = s->yuv_buf_size;
+ rep.num_fds = YUV_COUNT;
+ for (int i=0; iyuv_ion[i].fd;
+ }
+ if (stream->tb) {
+ stream->tbuffer = s->yuv_tb;
+ } else {
+ stream->queue = pool_get_queue(&s->yuv_pool);
+ }
+ } else if (stream_type == VISION_STREAM_YUV_FRONT) {
+ stream_bufs->width = s->yuv_front_width;
+ stream_bufs->height = s->yuv_front_height;
+ stream_bufs->stride = s->yuv_front_width;
+ stream_bufs->buf_len = s->yuv_front_buf_size;
+ rep.num_fds = YUV_COUNT;
+ for (int i=0; iyuv_front_ion[i].fd;
+ }
+ if (stream->tb) {
+ assert(false);
+ } else {
+ stream->queue = pool_get_queue(&s->yuv_front_pool);
+ }
+ } else {
+ assert(false);
+ }
+
+ if (stream_type == VISION_STREAM_RGB_BACK ||
+ stream_type == VISION_STREAM_RGB_FRONT) {
+ stream_bufs->buf_info.ui_info = (VisionUIInfo){
+ .transformed_width = s->model.in.transformed_width,
+ .transformed_height = s->model.in.transformed_height,
+ };
+ }
+ vipc_send(fd, &rep);
+ streams[stream_type].subscribed = true;
+ } else if (p.type == VIPC_STREAM_RELEASE) {
+ // printf("client release f %d %d\n", p.d.stream_rel.type, p.d.stream_rel.idx);
+ int si = p.d.stream_rel.type;
+ assert(si < VISION_STREAM_MAX);
+ if (streams[si].tb) {
+ tbuffer_release(streams[si].tbuffer, p.d.stream_rel.idx);
+ } else {
+ poolq_release(streams[si].queue, p.d.stream_rel.idx);
+ }
+ streams[p.d.stream_rel.type].bufs_outstanding--;
+ } else {
+ assert(false);
+ }
+ } else {
+ int stream_i = VISION_STREAM_MAX;
+ for (int i=2; iyuv_metas[idx].frame_id;
+ rep.d.stream_acq.extra.timestamp_eof = s->yuv_metas[idx].timestamp_eof;
+ } else if (stream_i == VISION_STREAM_YUV_FRONT) {
+ rep.d.stream_acq.extra.frame_id = s->yuv_front_metas[idx].frame_id;
+ rep.d.stream_acq.extra.timestamp_eof = s->yuv_front_metas[idx].timestamp_eof;
+ }
+ vipc_send(fd, &rep);
+ }
+ }
+ }
+
+ LOG("client end fd %d\n", fd);
+
+ for (int i=0; iclients_lock);
+ client->running = false;
+ pthread_mutex_unlock(&s->clients_lock);
+
+ return NULL;
+}
+
+void* visionserver_thread(void* arg) {
+ int err;
+ VisionState *s = (VisionState*)arg;
+
+ set_thread_name("visionserver");
+
+ zsock_t *terminate = zsock_new_sub(">inproc://terminate", "");
+ assert(terminate);
+ void* terminate_raw = zsock_resolve(terminate);
+
+ unlink(VIPC_SOCKET_PATH);
+
+ int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0);
+ struct sockaddr_un addr = {
+ .sun_family = AF_UNIX,
+ .sun_path = VIPC_SOCKET_PATH,
+ };
+ err = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
+ assert(err == 0);
+
+ err = listen(sock, 3);
+ assert(err == 0);
+
+ // printf("waiting\n");
+
+ while (!do_exit) {
+ zmq_pollitem_t polls[2] = {{0}};
+ polls[0].socket = terminate_raw;
+ polls[0].events = ZMQ_POLLIN;
+ polls[1].fd = sock;
+ polls[1].events = ZMQ_POLLIN;
+
+ int ret = zmq_poll(polls, ARRAYSIZE(polls), -1);
+ if (ret < 0) {
+ LOGE("poll failed (%d)", ret);
+ break;
+ }
+ if (polls[0].revents) {
+ break;
+ } else if (!polls[1].revents) {
+ continue;
+ }
+
+ int fd = accept(sock, NULL, NULL);
+ assert(fd >= 0);
+
+ pthread_mutex_lock(&s->clients_lock);
+
+ int client_idx = 0;
+ for (; client_idx < MAX_CLIENTS; client_idx++) {
+ if (!s->clients[client_idx].running) break;
+ }
+
+ if (client_idx >= MAX_CLIENTS) {
+ LOG("ignoring visionserver connection, max clients connected");
+ close(fd);
+
+ pthread_mutex_unlock(&s->clients_lock);
+ continue;
+ }
+
+ VisionClientState *client = &s->clients[client_idx];
+ client->s = s;
+ client->fd = fd;
+ client->running = true;
+
+ err = pthread_create(&client->thread_handle, NULL,
+ visionserver_client_thread, client);
+ assert(err == 0);
+
+ pthread_mutex_unlock(&s->clients_lock);
+ }
+
+ for (int i=0; iclients_lock);
+ bool running = s->clients[i].running;
+ pthread_mutex_unlock(&s->clients_lock);
+ if (running) {
+ err = pthread_join(s->clients[i].thread_handle, NULL);
+ assert(err == 0);
+ }
+ }
+
+ close(sock);
+ zsock_destroy(&terminate);
+
+ return NULL;
+}
+
+void* monitoring_thread(void *arg) {
+ int err;
+ VisionState *s = (VisionState*)arg;
+
+ set_thread_name("monitoring");
+
+ TBuffer *tb = pool_get_tbuffer(&s->yuv_front_pool);
+
+ cl_command_queue q = clCreateCommandQueue(s->context, s->device_id, 0, &err);
+ assert(err == 0);
+
+ double last = 0;
+ while (!do_exit) {
+ int buf_idx = tbuffer_acquire(tb);
+ if (buf_idx < 0) {
+ break;
+ }
+
+ FrameMetadata frame_data = s->yuv_front_metas[buf_idx];
+
+ // only process every frame
+ if ((frame_data.frame_id % 1) == 0) {
+
+ double t1 = millis_since_boot();
+
+ MonitoringResult res = monitoring_eval_frame(&s->monitoring, q,
+ s->yuv_front_cl[buf_idx], s->yuv_front_width, s->yuv_front_height);
+
+ // for (int i=0; i<6; i++) {
+ // printf("%f ", res.vs[i]);
+ // }
+ // printf("\n");
+
+ // send driver monitoring packet
+ {
+ capnp::MallocMessageBuilder msg;
+ cereal::Event::Builder event = msg.initRoot();
+ event.setLogMonoTime(nanos_since_boot());
+
+ auto framed = event.initDriverMonitoring();
+ framed.setFrameId(frame_data.frame_id);
+
+ kj::ArrayPtr descriptor_vs(&res.vs[0], ARRAYSIZE(res.vs));
+ framed.setDescriptor(descriptor_vs);
+
+ framed.setStd(res.std);
+
+ auto words = capnp::messageToFlatArray(msg);
+ auto bytes = words.asBytes();
+ zmq_send(s->monitoring_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT);
+ }
+
+ double t2 = millis_since_boot();
+
+ LOGD("monitoring process: %.2fms, from last %.2fms", t2-t1, t1-last);
+ last = t1;
+ }
+
+ tbuffer_release(tb, buf_idx);
+ }
+
+ return NULL;
+}
+
+void* frontview_thread(void *arg) {
+ int err;
+ VisionState *s = (VisionState*)arg;
+
+ set_thread_name("frontview");
+
+ cl_command_queue q = clCreateCommandQueue(s->context, s->device_id, 0, &err);
+ assert(err == 0);
+
+ for (int cnt = 0; !do_exit; cnt++) {
+ int buf_idx = tbuffer_acquire(&s->cameras.front.camera_tb);
+ if (buf_idx < 0) {
+ break;
+ }
+
+ int ui_idx = tbuffer_select(&s->ui_front_tb);
+ FrameMetadata frame_data = s->cameras.front.camera_bufs_metadata[buf_idx];
+
+ double t1 = millis_since_boot();
+
+ err = clSetKernelArg(s->krnl_debayer_front, 0, sizeof(cl_mem), &s->front_camera_bufs_cl[buf_idx]);
+ assert(err == 0);
+ err = clSetKernelArg(s->krnl_debayer_front, 1, sizeof(cl_mem), &s->rgb_front_bufs_cl[ui_idx]);
+ assert(err == 0);
+ float digital_gain = 1.0;
+ err = clSetKernelArg(s->krnl_debayer_front, 2, sizeof(float), &digital_gain);
+ assert(err == 0);
+
+ cl_event debayer_event;
+ const size_t debayer_work_size = s->rgb_front_height;
+ const size_t debayer_local_work_size = 128;
+ err = clEnqueueNDRangeKernel(q, s->krnl_debayer_front, 1, NULL,
+ &debayer_work_size, &debayer_local_work_size, 0, 0, &debayer_event);
+ assert(err == 0);
+ clWaitForEvents(1, &debayer_event);
+ clReleaseEvent(debayer_event);
+
+ tbuffer_release(&s->cameras.front.camera_tb, buf_idx);
+
+ visionbuf_sync(&s->rgb_front_bufs[ui_idx], VISIONBUF_SYNC_FROM_DEVICE);
+
+ // auto exposure
+ const uint8_t *bgr_front_ptr = (const uint8_t*)s->rgb_front_bufs[ui_idx].addr;
+#ifndef DEBUG_DRIVER_MONITOR
+ if (cnt % 3 == 0)
+#endif
+ {
+
+ // for driver autoexposure, use bottom right corner
+ const int y_start = s->rgb_front_height / 3;
+ const int y_end = s->rgb_front_height;
+ const int x_start = s->rgb_front_width * 2 / 3;
+ const int x_end = s->rgb_front_width;
+
+ uint32_t lum_binning[256] = {0,};
+ for (int y = y_start; y < y_end; ++y) {
+ for (int x = x_start; x < x_end; x += 2) { // every 2nd col
+ const uint8_t *pix = &bgr_front_ptr[y * s->rgb_front_stride + x * 3];
+ unsigned int lum = (unsigned int)pix[0] + pix[1] + pix[2];
+#ifdef DEBUG_DRIVER_MONITOR
+ uint8_t *pix_rw = (uint8_t *)pix;
+
+ // set all the autoexposure pixels to pure green (pixel format is bgr)
+ pix_rw[0] = pix_rw[2] = 0;
+ pix_rw[1] = 0xff;
+#endif
+ lum_binning[std::min(lum / 3, 255u)]++;
+ }
+ }
+ const unsigned int lum_total = (y_end - y_start) * (x_end - x_start)/2;
+ unsigned int lum_cur = 0;
+ int lum_med = 0;
+ for (lum_med=0; lum_med<256; lum_med++) {
+ lum_cur += lum_binning[lum_med];
+ if (lum_cur >= lum_total / 2) {
+ break;
+ }
+ }
+ camera_autoexposure(&s->cameras.front, lum_med / 256.0);
+ }
+
+ // push YUV buffer
+ int yuv_idx = pool_select(&s->yuv_front_pool);
+ s->yuv_front_metas[yuv_idx] = frame_data;
+
+ uint8_t *bgr_ptr = (uint8_t*)s->rgb_front_bufs[ui_idx].addr;
+ libyuv::RGB24ToI420(bgr_ptr, s->rgb_front_stride,
+ s->yuv_front_bufs[yuv_idx].y, s->yuv_front_width,
+ s->yuv_front_bufs[yuv_idx].u, s->yuv_front_width/2,
+ s->yuv_front_bufs[yuv_idx].v, s->yuv_front_width/2,
+ s->rgb_front_width, s->rgb_front_height);
+
+ s->yuv_front_metas[yuv_idx] = frame_data;
+ visionbuf_sync(&s->yuv_front_ion[yuv_idx], VISIONBUF_SYNC_TO_DEVICE);
+
+ // no reference required cause we don't use this in visiond
+ //pool_acquire(&s->yuv_front_pool, yuv_idx);
+ pool_push(&s->yuv_front_pool, yuv_idx);
+ //pool_release(&s->yuv_front_pool, yuv_idx);
+
+ /*FILE *f = fopen("/tmp/test2", "wb");
+ printf("%d %d\n", s->rgb_front_height, s->rgb_front_stride);
+ fwrite(bgr_front_ptr, 1, s->rgb_front_stride * s->rgb_front_height, f);
+ fclose(f);*/
+
+ tbuffer_dispatch(&s->ui_front_tb, ui_idx);
+
+ double t2 = millis_since_boot();
+
+ LOGD("front process: %.2fms", t2-t1);
+ }
+
+ return NULL;
+}
+
+void* processing_thread(void *arg) {
+ int err;
+ VisionState *s = (VisionState*)arg;
+
+ set_thread_name("processing");
+
+ err = set_realtime_priority(1);
+ LOG("setpriority returns %d", err);
+
+ // init cl stuff
+ const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0};
+ cl_command_queue q = clCreateCommandQueueWithProperties(s->context, s->device_id, props, &err);
+ assert(err == 0);
+
+ zsock_t *model_sock = zsock_new_pub("@tcp://*:8009");
+ assert(model_sock);
+ void *model_sock_raw = zsock_resolve(model_sock);
+
+#ifdef SEND_NET_INPUT
+ zsock_t *img_sock = zsock_new_pub("@tcp://*:9000");
+ assert(img_sock);
+ void *img_sock_raw = zsock_resolve(img_sock);
+#else
+ void *img_sock_raw = NULL;
+#endif
+
+#ifdef DUMP_RGB
+ FILE *dump_rgb_file = fopen("/sdcard/dump.rgb", "wb");
+#endif
+
+ // init the net
+ LOG("processing start!");
+
+ for (int cnt = 0; !do_exit; cnt++) {
+ int buf_idx = tbuffer_acquire(&s->cameras.rear.camera_tb);
+ // int buf_idx = camera_acquire_buffer(s);
+ if (buf_idx < 0) {
+ break;
+ }
+
+ double t1 = millis_since_boot();
+
+ FrameMetadata frame_data = s->cameras.rear.camera_bufs_metadata[buf_idx];
+ uint32_t frame_id = frame_data.frame_id;
+
+ if (frame_id == -1) {
+ LOGE("no frame data? wtf");
+ tbuffer_release(&s->cameras.rear.camera_tb, buf_idx);
+ continue;
+ }
+
+ int ui_idx = tbuffer_select(&s->ui_tb);
+ int rgb_idx = ui_idx;
+ // printf("idx %d\n", rgb_idx);
+
+ /*FILE *f = fopen("/tmp/test_dump", "wb");
+ fwrite(s->camera_bufs[buf_idx].addr, 1, s->camera_bufs[buf_idx].len, f);
+ fclose(f);*/
+
+ cl_event debayer_event;
+ if (s->cameras.rear.ci.bayer) {
+ err = clSetKernelArg(s->krnl_debayer_rear, 0, sizeof(cl_mem), &s->camera_bufs_cl[buf_idx]);
+ cl_check_error(err);
+ err = clSetKernelArg(s->krnl_debayer_rear, 1, sizeof(cl_mem), &s->rgb_bufs_cl[rgb_idx]);
+ cl_check_error(err);
+ err = clSetKernelArg(s->krnl_debayer_rear, 2, sizeof(float), &s->cameras.rear.digital_gain);
+ assert(err == 0);
+
+ const size_t debayer_work_size = s->rgb_height; // doesn't divide evenly, is this okay?
+ const size_t debayer_local_work_size = 128;
+ err = clEnqueueNDRangeKernel(q, s->krnl_debayer_rear, 1, NULL,
+ &debayer_work_size, &debayer_local_work_size, 0, 0, &debayer_event);
+ assert(err == 0);
+ } else {
+ assert(s->rgb_buf_size >= s->frame_size);
+ assert(s->rgb_stride == s->frame_stride);
+ err = clEnqueueCopyBuffer(q, s->camera_bufs_cl[buf_idx], s->rgb_bufs_cl[rgb_idx],
+ 0, 0, s->rgb_buf_size, 0, 0, &debayer_event);
+ assert(err == 0);
+ }
+
+ clWaitForEvents(1, &debayer_event);
+ clReleaseEvent(debayer_event);
+
+ tbuffer_release(&s->cameras.rear.camera_tb, buf_idx);
+
+ visionbuf_sync(&s->rgb_bufs[rgb_idx], VISIONBUF_SYNC_FROM_DEVICE);
+
+
+ double t2 = millis_since_boot();
+
+ uint8_t *bgr_ptr = (uint8_t*)s->rgb_bufs[rgb_idx].addr;
+
+#ifdef DUMP_RGB
+ if (cnt % 20 == 0) {
+ fwrite(bgr_ptr, s->rgb_buf_size, 1, dump_rgb_file);
+ }
+#endif
+
+ double yt1 = millis_since_boot();
+
+ int yuv_idx = pool_select(&s->yuv_pool);
+
+ s->yuv_metas[yuv_idx] = frame_data;
+
+ uint8_t* yuv_ptr_y = s->yuv_bufs[yuv_idx].y;
+ uint8_t* yuv_ptr_u = s->yuv_bufs[yuv_idx].u;
+ uint8_t* yuv_ptr_v = s->yuv_bufs[yuv_idx].v;
+ cl_mem yuv_cl = s->yuv_cl[yuv_idx];
+
+ libyuv::RGB24ToI420(bgr_ptr, s->rgb_stride,
+ yuv_ptr_y, s->yuv_width,
+ yuv_ptr_u, s->yuv_width/2,
+ yuv_ptr_v, s->yuv_width/2,
+ s->rgb_width, s->rgb_height);
+
+ double yt2 = millis_since_boot();
+
+ visionbuf_sync(&s->yuv_ion[yuv_idx], VISIONBUF_SYNC_TO_DEVICE);
+
+ // keep another reference around till were done processing
+ pool_acquire(&s->yuv_pool, yuv_idx);
+
+ pool_push(&s->yuv_pool, yuv_idx);
+
+ pthread_mutex_lock(&s->transform_lock);
+ mat3 transform = s->cur_transform;
+ const bool run_model_this_iter = s->run_model;
+ pthread_mutex_unlock(&s->transform_lock);
+
+ double mt1 = 0, mt2 = 0;
+ if (run_model_this_iter) {
+
+ mat3 model_transform = matmul3(s->yuv_transform, transform);
+
+ mt1 = millis_since_boot();
+ s->model_bufs[ui_idx] =
+ model_eval_frame(&s->model, q, yuv_cl, s->yuv_width, s->yuv_height,
+ model_transform, img_sock_raw);
+ mt2 = millis_since_boot();
+
+ model_publish(model_sock_raw, frame_id, model_transform, s->model_bufs[ui_idx]);
+ }
+
+ // send frame event
+ {
+ capnp::MallocMessageBuilder msg;
+ cereal::Event::Builder event = msg.initRoot();
+ event.setLogMonoTime(nanos_since_boot());
+
+ auto framed = event.initFrame();
+ framed.setFrameId(frame_data.frame_id);
+ framed.setEncodeId(cnt);
+ framed.setTimestampEof(frame_data.timestamp_eof);
+ framed.setFrameLength(frame_data.frame_length);
+ framed.setIntegLines(frame_data.integ_lines);
+ framed.setGlobalGain(frame_data.global_gain);
+ framed.setLensPos(frame_data.lens_pos);
+ framed.setLensSag(frame_data.lens_sag);
+ framed.setLensErr(frame_data.lens_err);
+ framed.setLensTruePos(frame_data.lens_true_pos);
+
+#ifndef QCOM
+ framed.setImage(kj::arrayPtr((const uint8_t*)s->yuv_ion[yuv_idx].addr, s->yuv_buf_size));
+#endif
+
+ kj::ArrayPtr transform_vs(&s->yuv_transform.v[0], 9);
+ framed.setTransform(transform_vs);
+
+ auto words = capnp::messageToFlatArray(msg);
+ auto bytes = words.asBytes();
+ zmq_send(s->recorder_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT);
+ }
+
+
+ tbuffer_dispatch(&s->ui_tb, ui_idx);
+
+ // auto exposure over big box
+ const int exposure_x = 290;
+ const int exposure_y = 282 + 40;
+ const int exposure_height = 314;
+ const int exposure_width = 560;
+ if (cnt % 3 == 0) {
+ // find median box luminance for AE
+ uint32_t lum_binning[256] = {0,};
+ for (int y=0; yyuv_width) + exposure_x + x];
+ lum_binning[lum]++;
+ }
+ }
+ const unsigned int lum_total = exposure_height * exposure_width;
+ unsigned int lum_cur = 0;
+ int lum_med = 0;
+ for (lum_med=0; lum_med<256; lum_med++) {
+ // shouldn't be any values less than 16 - yuv footroom
+ lum_cur += lum_binning[lum_med];
+ if (lum_cur >= lum_total / 2) {
+ break;
+ }
+ }
+ // double avg = (double)acc / (big_box_width * big_box_height) - 16;
+ // printf("avg %d\n", lum_med);
+
+ camera_autoexposure(&s->cameras.rear, lum_med / 256.0);
+ }
+
+ pool_release(&s->yuv_pool, yuv_idx);
+
+ // if (cnt%40 == 0) {
+ // FILE* of = fopen("/sdcard/tmp.yuv", "wb");
+ // fwrite(transformed_ptr_y, 1, s->transformed_width*s->transformed_height, of);
+ // fwrite(transformed_ptr_u, 1, (s->transformed_width/2)*(s->transformed_height/2), of);
+ // fwrite(transformed_ptr_v, 1, (s->transformed_width/2)*(s->transformed_height/2), of);
+ // fclose(of);
+ // }
+
+ double t5 = millis_since_boot();
+
+ LOGD("queued: %.2fms, yuv: %.2f, model: %.2fms | processing: %.3fms",
+ (t2-t1), (yt2-yt1), (mt2-mt1), (t5-t1));
+ }
+
+#ifdef DUMP_RGB
+ fclose(dump_rgb_file);
+#endif
+
+ zsock_destroy(&model_sock);
+
+ return NULL;
+}
+
+void* live_thread(void *arg) {
+ int err;
+ VisionState *s = (VisionState*)arg;
+
+ set_thread_name("live");
+
+ zsock_t *terminate = zsock_new_sub(">inproc://terminate", "");
+ assert(terminate);
+
+ zsock_t *liveCalibration_sock = zsock_new_sub(">tcp://127.0.0.1:8019", "");
+ assert(liveCalibration_sock);
+
+ zpoller_t *poller = zpoller_new(liveCalibration_sock, terminate, NULL);
+ assert(poller);
+
+ while (!do_exit) {
+ zsock_t *which = (zsock_t*)zpoller_wait(poller, -1);
+ if (which == terminate || which == NULL) {
+ break;
+ }
+
+ zmq_msg_t msg;
+ err = zmq_msg_init(&msg);
+ assert(err == 0);
+
+ err = zmq_msg_recv(&msg, zsock_resolve(which), 0);
+ assert(err >= 0);
+ size_t len = zmq_msg_size(&msg);
+
+ // make copy due to alignment issues, will be freed on out of scope
+ auto amsg = kj::heapArray((len / sizeof(capnp::word)) + 1);
+ memcpy(amsg.begin(), (const uint8_t*)zmq_msg_data(&msg), len);
+
+ // track camera frames to sync to encoder
+ capnp::FlatArrayMessageReader cmsg(amsg);
+ cereal::Event::Reader event = cmsg.getRoot();
+
+ if (event.isLiveCalibration()) {
+ pthread_mutex_lock(&s->transform_lock);
+#ifdef BIGMODEL
+ auto wm2 = event.getLiveCalibration().getWarpMatrixBig();
+#else
+ auto wm2 = event.getLiveCalibration().getWarpMatrix2();
+#endif
+ assert(wm2.size() == 3*3);
+ for (int i=0; i<3*3; i++) {
+ s->cur_transform.v[i] = wm2[i];
+ }
+ s->run_model = true;
+ pthread_mutex_unlock(&s->transform_lock);
+ }
+
+ zmq_msg_close(&msg);
+ }
+
+ zpoller_destroy(&poller);
+ zsock_destroy(&terminate);
+
+ zsock_destroy(&liveCalibration_sock);
+
+ return NULL;
+}
+
+void set_do_exit(int sig) {
+ do_exit = 1;
+}
+
+void party(VisionState *s, bool nomodel) {
+ int err;
+
+ s->terminate_pub = zsock_new_pub("@inproc://terminate");
+ assert(s->terminate_pub);
+
+#ifndef __APPLE__
+ pthread_t visionserver_thread_handle;
+ err = pthread_create(&visionserver_thread_handle, NULL,
+ visionserver_thread, s);
+ assert(err == 0);
+#endif
+
+ pthread_t proc_thread_handle;
+ err = pthread_create(&proc_thread_handle, NULL,
+ processing_thread, s);
+ assert(err == 0);
+
+
+ pthread_t frontview_thread_handle;
+ err = pthread_create(&frontview_thread_handle, NULL,
+ frontview_thread, s);
+ assert(err == 0);
+
+ pthread_t monitoring_thread_handle;
+ err = pthread_create(&monitoring_thread_handle, NULL, monitoring_thread, s);
+ assert(err == 0);
+
+ pthread_t live_thread_handle;
+ err = pthread_create(&live_thread_handle, NULL,
+ live_thread, s);
+ assert(err == 0);
+
+ // priority for cameras
+ err = set_realtime_priority(1);
+ LOG("setpriority returns %d", err);
+
+ cameras_run(&s->cameras);
+
+ tbuffer_stop(&s->ui_tb);
+ tbuffer_stop(&s->ui_front_tb);
+ pool_stop(&s->yuv_pool);
+ pool_stop(&s->yuv_front_pool);
+
+ zsock_signal(s->terminate_pub, 0);
+
+ LOG("joining frontview_thread");
+ err = pthread_join(frontview_thread_handle, NULL);
+ assert(err == 0);
+
+#ifndef __APPLE__
+ LOG("joining visionserver_thread");
+ err = pthread_join(visionserver_thread_handle, NULL);
+ assert(err == 0);
+#endif
+
+ LOG("joining proc_thread");
+ err = pthread_join(proc_thread_handle, NULL);
+ assert(err == 0);
+
+ LOG("joining live_thread");
+ err = pthread_join(live_thread_handle, NULL);
+ assert(err == 0);
+
+ zsock_destroy (&s->terminate_pub);
+}
+
+}
+
+// TODO: make a version of visiond that runs on pc using streamed video from EON.
+// BOUNTY: free EON+panda+giraffe
+
+int main(int argc, char **argv) {
+ int err;
+
+ zsys_handler_set(NULL);
+ signal(SIGINT, (sighandler_t)set_do_exit);
+ signal(SIGTERM, (sighandler_t)set_do_exit);
+
+ // boringssl via curl via the calibration api can sometimes
+ // try to write to a closed socket. just ignore SIGPIPE
+ signal(SIGPIPE, SIG_IGN);
+
+ bool test_run = false;
+ if (argc > 1 && strcmp(argv[1], "-t") == 0) {
+ // immediately tear everything down. useful for caching opencl
+ test_run = true;
+ }
+
+ bool no_model = false;
+ if (argc > 1 && strcmp(argv[1], "--no-model") == 0) {
+ no_model = true;
+ }
+
+ VisionState state = {0};
+ VisionState *s = &state;
+
+ clu_init();
+ cl_init(s);
+
+ model_init(&s->model, s->device_id, s->context, true);
+ monitoring_init(&s->monitoring, s->device_id, s->context);
+
+ // s->zctx = zctx_shadow_zmq_ctx(zsys_init());
+
+ cameras_init(&s->cameras);
+
+ s->frame_width = s->cameras.rear.ci.frame_width;
+ s->frame_height = s->cameras.rear.ci.frame_height;
+ s->frame_stride = s->cameras.rear.ci.frame_stride;
+ s->frame_size = s->cameras.rear.frame_size;
+
+ // Do not run the model until we receive valid calibration.
+ s->run_model = false;
+ pthread_mutex_init(&s->transform_lock, NULL);
+
+ init_buffers(s);
+
+ s->recorder_sock = zsock_new_pub("@tcp://*:8002");
+ assert(s->recorder_sock);
+ s->recorder_sock_raw = zsock_resolve(s->recorder_sock);
+
+ s->monitoring_sock = zsock_new_pub("@tcp://*:8063");
+ assert(s->monitoring_sock);
+ s->monitoring_sock_raw = zsock_resolve(s->monitoring_sock);
+
+ cameras_open(&s->cameras, &s->camera_bufs[0], &s->focus_bufs[0], &s->stats_bufs[0], &s->front_camera_bufs[0]);
+
+ if (test_run) {
+ do_exit = true;
+ }
+ party(s, no_model);
+
+ zsock_destroy(&s->recorder_sock);
+ zsock_destroy(&s->monitoring_sock);
+ // zctx_destroy(&s->zctx);
+
+ model_free(&s->model);
+ monitoring_free(&s->monitoring);
+ free_buffers(s);
+
+ cl_free(s);
+
+ return 0;
+}