diff --git a/.gitignore b/.gitignore
index 47d1a66875..1d91f80a14 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
.tags
.ipynb_checkpoints
.idea
+.sconsign.dblite
model2.png
a.out
@@ -19,6 +20,8 @@ a.out
*.class
*.pyxbldc
*.vcd
+lane.cpp
+loc*.cpp
config.json
clcache
diff --git a/README.md b/README.md
index 5e4a84e439..232d018f3b 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,36 @@
+[](#)
+
Welcome to openpilot
======
-[openpilot](http://github.com/commaai/openpilot) is an open source driving agent.
-
-Currently it performs the functions of Adaptive Cruise Control (ACC) and Lane Keeping Assist System (LKAS) for Hondas, Acuras and Toyotas. It's about on par with Tesla Autopilot at launch, and better than [all other manufacturers](http://www.thedrive.com/tech/5707/the-war-for-autonomous-driving-part-iii-us-vs-germany-vs-japan).
+[openpilot](http://github.com/commaai/openpilot) is an open source driving agent. Currently it performs the functions of Adaptive Cruise Control (ACC) and Lane Keeping Assist System (LKAS) for Hondas, Acuras, Toyotas, and a Chevy. It's about on par with Tesla Autopilot and GM Super Cruise, and better than [all other manufacturers](http://www.thedrive.com/tech/5707/the-war-for-autonomous-driving-part-iii-us-vs-germany-vs-japan).
The openpilot codebase has been written to be concise and enable rapid prototyping. We look forward to your contributions - improving real vehicle automation has never been easier.
-Here are [some](https://www.youtube.com/watch?v=9OwTJFuDI7g) [videos](https://www.youtube.com/watch?v=64Wvt5pYQmE) [of](https://www.youtube.com/watch?v=6IW7Nejsr3A) [it](https://www.youtube.com/watch?v=-VN1YcC83nA) [running](https://www.youtube.com/watch?v=EQJZvVeihZk). And a really cool [tutorial](https://www.youtube.com/watch?v=PwOnsT2UW5o).
-
Community
------
-openpilot is supported by [comma.ai](https://comma.ai/)
+openpilot is supported by [comma.ai](https://comma.ai/).
We have a [Twitter you should follow](https://twitter.com/comma_ai).
Also, we have a 3500+ person [community on slack](https://slack.comma.ai).
+
+
+  |
+  |
+  |
+  |
+
+
+  |
+  |
+  |
+  |
+
+
+
Hardware
------
@@ -28,68 +41,57 @@ Install openpilot on a neo device by entering ``https://openpilot.comma.ai`` dur
Supported Cars
------
-### Honda + Acura ###
-
-- Honda Accord 2018 with Honda Sensing (alpha!)
- - Uses stock Honda Sensing for longitudinal control
-
-- Honda Civic 2016+ with Honda Sensing
- - Due to limitations in steering firmware, steering is disabled below 12 mph
- - Note that the hatchback model is not supported
-
-- Honda Civic Hatchback 2017+ with Honda Sensing (alpha!)
- - Due to limitations in steering firmware, steering is disabled below 12 mph
- - Uses stock Honda Sensing for longitudinal control
-
-- Honda CR-V 2017-2018 with Honda Sensing (alpha!)
- - Due to limitations in steering firmware, steering is disabled below 12 mph
- - Uses stock Honda Sensing for longitudinal control
-
-- Honda CR-V Touring 2015-2016
- - Can only be enabled above 25 mph
-
-- Honda Odyssey 2018 with Honda Sensing (alpha!)
- - Can only be enabled above 25 mph
-
-- Honda Pilot 2017 with Honda Sensing (alpha!)
- - Can only be enabled above 27 mph
-
-- Honda Ridgeline 2017 with Honda Sensing (alpha!)
- - Can only be enabled above 27 mph
+| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below |
+| ------- | ---------------------- | -------------------- | ------- | ------------ | -------------- | -------------- |
+| Acura | ILX 2016 | AcuraWatch Plus | Yes | Yes | 25mph* | 12mph |
+| Acura | ILX 2017 | AcuraWatch Plus | Yes | Yes | 25mph* | 12mph |
+| Acura | RDX 2018 | AcuraWatch Plus | Yes | Yes | 25mph* | 12mph |
+| GM | Volt 2017 | Driver Confidence II | Yes | Yes | 0mph | 0mph |
+| GM | Volt 2018 | Driver Confidence II | Yes | Yes | 0mph | 0mph |
+| Honda | Accord 2018 | All | Yes | Stock | 0mph | 3mph |
+| Honda | Civic 2016 *(Sedan)* | Honda Sensing | Yes | Yes | 0mph | 12mph |
+| Honda | Civic 2017 *(Sedan)* | Honda Sensing | Yes | Yes | 0mph | 12mph |
+| Honda | Civic 2017 *(Hatch)* | Honda Sensing | Yes | Stock | 0mph | 12mph |
+| Honda | Civic 2018 *(Sedan)* | Honda Sensing | Yes | Yes | 0mph | 12mph |
+| Honda | CR-V 2015 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Honda | CR-V 2016 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Honda | CR-V 2017 | Honda Sensing | Yes | Stock | 0mph | 12mph |
+| Honda | CR-V 2018 | Honda Sensing | Yes | Stock | 0mph | 12mph |
+| Honda | Odyssey 2017 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Honda | Odyssey 2018 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Honda | Pilot 2017 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Honda | Pilot 2018 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Honda | Ridgeline 2017 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Honda | Ridgeline 2018 | Honda Sensing | Yes | Yes | 25mph* | 12mph |
+| Lexus | RX Hybrid 2017 | All | Yes | Yes | 0mph | 0mph |
+| Lexus | RX Hybrid 2018 | All | Yes | Yes | 0mph | 0mph |
+| Toyota | Corolla 2017 | All | Yes | Yes | 20mph | 0mph |
+| Toyota | Corolla 2018 | All | Yes | Yes | 20mph | 0mph |
+| Toyota | Prius 2016 | TSS-P | Yes | Yes | 0mph | 0mph |
+| Toyota | Prius 2017 | All | Yes | Yes | 0mph | 0mph |
+| Toyota | Prius 2018 | All | Yes | Yes | 0mph | 0mph |
+| Toyota | Prius Prime 2017 | All | Yes | Yes | 0mph | 0mph |
+| Toyota | Prius Prime 2018 | All | Yes | Yes | 0mph | 0mph |
+| Toyota | Rav4 2016 | TSS-P | Yes | Yes | 20mph | 0mph |
+| Toyota | Rav4 2017 | All | Yes | Yes | 20mph | 0mph |
+| Toyota | Rav4 2018 | All | Yes | Yes | 20mph | 0mph |
+| Toyota | Rav4 Hybrid 2017 | All | Yes | Yes | 0mph | 0mph |
+| Toyota | Rav4 Hybrid 2018 | All | Yes | Yes | 0mph | 0mph |
+
+
+*[Comma Pedal](https://community.comma.ai/wiki/index.php/Comma_Pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. Here is how to [build a Comma Pedal](https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8). ***NOTE: The Comma Pedal is not officially supported by [comma.ai](https://comma.ai)***
-- Acura ILX 2016 with AcuraWatch Plus
- - Due to use of the cruise control for gas, it can only be enabled above 25 mph
-
-- Acura RDX 2018 with AcuraWatch Plus (alpha!)
- - Can only be enabled above 25 mph
-
-### Toyota + Lexus ###
-
-- Toyota RAV-4 2016+ non-hybrid with TSS-P
- - By default it uses stock Toyota ACC for longitudinal control
- - openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Rav4_.28for_openpilot.29) and can be enabled above 20 mph
-
-- Toyota Prius 2017+
- - By default it uses stock Toyota ACC for longitudinal control
- - openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Prius_.28for_openpilot.29)
- - Lateral control needs improvements
-
-- Toyota RAV-4 2017+ hybrid
- - By default it uses stock Toyota ACC for longitudinal control
- - openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Rav4_.28for_openpilot.29) and can do stop and go
-
-- Toyota Corolla 2017+
- - By default it uses stock Toyota ACC for longitudinal control
- - openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Corolla_.28for_openpilot.29) and can be enabled above 20 mph
+Community Maintained Cars
+------
-- Lexus RX 2017+ hybrid (alpha!)
- - By default it uses stock Lexus ACC for longitudinal control
- - openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Lexus_RX_hybrid)
+| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below |
+| ------- | -----------------------| -------------------- | ------- | ------------ | ----------- | ------------ |
+| Tesla | Model S 2012 | All | Yes | Not yet | Not applicable | 0mph |
+| Tesla | Model S 2013 | All | Yes | Not yet | Not applicable | 0mph |
-### GM (Chevrolet + Cadillac) ###
+[[Tesla Pull Request]](https://github.com/commaai/openpilot/pull/246)
-- Chevrolet Volt Premier 2017+ with Driver Confidence II package
- - Read the [installation guide](https://www.zoneos.com/volt.htm)
+*Community Maintained Cars are not confirmed by comma.ai to meet our safety model. Be extra cautious using them.
In Progress Cars
------
@@ -97,14 +99,9 @@ In Progress Cars
- '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 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, GS, F, RX, RXH, LX, NX, NXH, LC, LCH, LS, LSH have this option.
+ - '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.
-Community Maintained Cars
-------
-
-- [Classic Tesla Model S (pre-AP)](https://github.com/commaai/openpilot/pull/246)
-
How can I add support for my car?
------
@@ -112,34 +109,53 @@ If your car has adaptive cruise control and lane keep assist, you are in luck. U
We've written a [porting guide](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) for Toyota that might help you after you have the basics figured out.
-Sadly, BMW, Audi, Volvo, and Mercedes all use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) and are unlikely to be supported any time soon. We also put time into a Ford port, but the steering has a 10 second cutout limitation that makes it unusable.
+- BMW, Audi, Volvo, and Mercedes all use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) and are unlikely to be supported any time soon.
+- 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 use a custom signaling protocol for steering that's unlikely to ever be upstreamed.
Directory structure
------
-
-- cereal -- The messaging spec used for all logs on the phone
-- common -- Library like functionality we've developed here
-- opendbc -- Files showing how to interpret data from cars
-- panda -- Code used to communicate on CAN and LIN
-- phonelibs -- Libraries used on the phone
-- selfdrive -- Code needed to drive the car
- - assets -- Fonts for ui
- - boardd -- Daemon to talk to the board
- - car -- Code that talks to the car and implements CarInterface
- - common -- Shared C/C++ code for the daemons
- - controls -- Python controls (PID loops etc) for the car
- - debug -- Tools to help you debug and do car ports
- - logcatd -- Android logcat as a service
- - loggerd -- Logger and uploader of car data
- - orbd -- Service generating ORB features from road camera
- - proclogd -- Logs information from proc
- - sensord -- IMU / GPS interface code
- - test/plant -- Car simulator running code through virtual maneuvers
- - ui -- The UI
- - visiond -- embedded vision pipeline
+ .
+ ├── apk # The apk files used for the UI
+ ├── cereal # The messaging spec used for all logs on EON
+ ├── common # Library like functionality we've developed here
+ ├── installer/updater # Manages auto-updates of openpilot
+ ├── opendbc # Files showing how to interpret data from cars
+ ├── panda # Code used to communicate on CAN and LIN
+ ├── phonelibs # Libraries used on EON
+ ├── pyextra # Libraries used on EON
+ └── selfdrive # Code needed to drive the car
+ ├── assets # Fonts and images for UI
+ ├── boardd # Daemon to talk to the board
+ ├── can # Helpers for parsing CAN messages
+ ├── car # Car specific code to read states and control actuators
+ ├── common # Shared C/C++ code for the daemons
+ ├── controls # Perception, planning and controls
+ ├── debug # Tools to help you debug and do car ports
+ ├── locationd # Soon to be home of precise location
+ ├── logcatd # Android logcat as a service
+ ├── loggerd # Logger and uploader of car data
+ ├── proclogd # Logs information from proc
+ ├── sensord # IMU / GPS interface code
+ ├── test # Car simulator running code through virtual maneuvers
+ ├── ui # The UI
+ └── visiond # Embedded vision pipeline
To understand how the services interact, see `selfdrive/service_list.yaml`
+User Data / chffr Account / Crash Reporting
+------
+
+By default openpilot creates an account and includes a client for chffr, our dashcam app. We use your data to train better models and improve openpilot for everyone.
+
+It's open source software, so you are free to disable it if you wish.
+
+It logs the road facing camera, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs.
+The user facing camera is only logged if you explicitly opt-in in settings.
+It does not log the microphone.
+
+By using it, you agree to [our privacy policy](https://community.comma.ai/privacy.html). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma.ai. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma.ai for the use of this data.
+
Testing on PC
------
@@ -150,28 +166,15 @@ There is rudimentary infrastructure to run a basic simulation and generate a rep
./run_docker_tests.sh
```
-The results are written to `selfdrive/test/tests/plant/out/longitudinal/index.html`
+The resulting plots are displayed in `selfdrive/test/tests/plant/out/longitudinal/index.html`
More extensive testing infrastructure and simulation environments are coming soon.
-User Data / chffr Account / Crash Reporting
-------
-
-By default openpilot creates an account and includes a client for chffr, our dashcam app. We use your data to train better models and improve openpilot for everyone.
-
-It's open source software, so you are free to disable it if you wish.
-
-It logs the road facing camera, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs.
-It does not log the user facing camera or the microphone.
-
-By using it, you agree to [our privacy policy](https://community.comma.ai/privacy.html). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma.ai. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma.ai for the use of this data.
-
Contributing
------
We welcome both pull requests and issues on
-[github](http://github.com/commaai/openpilot). See the TODO file for a list of
-good places to start.
+[github](http://github.com/commaai/openpilot). Bug fixes and new car support encouraged.
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 711b5c23fc..a515873642 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,3 +1,14 @@
+Version 0.5 (2018-07-11)
+========================
+ * Driver Monitoring (beta) option in settings!
+ * Make visiond, loggerd and UI use less resources
+ * 60 FPS UI
+ * Better car parameters for most cars
+ * New sidebar with stats
+ * Remove Waze and Spotify to free up system resources
+ * Remove rear view mirror option
+ * Calibration 3x faster
+
Version 0.4.7.2 (2018-06-25)
==========================
* Fix loggerd lag issue
diff --git a/apk/ai.comma.plus.frame.apk b/apk/ai.comma.plus.frame.apk
index 8a8d461aae..eaf67b1c70 100644
Binary files a/apk/ai.comma.plus.frame.apk and b/apk/ai.comma.plus.frame.apk differ
diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk
index c6a2832bf1..db4a96af8b 100644
Binary files a/apk/ai.comma.plus.offroad.apk and b/apk/ai.comma.plus.offroad.apk differ
diff --git a/apk/external/.gitignore b/apk/external/.gitignore
deleted file mode 100644
index 4d46f978e3..0000000000
--- a/apk/external/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-src/*
-out/*
diff --git a/apk/external/com.spotify.music.apkpatch b/apk/external/com.spotify.music.apkpatch
deleted file mode 100644
index 9d8c155a02..0000000000
Binary files a/apk/external/com.spotify.music.apkpatch and /dev/null differ
diff --git a/apk/external/com.waze.apkpatch b/apk/external/com.waze.apkpatch
deleted file mode 100644
index 31e86c5645..0000000000
Binary files a/apk/external/com.waze.apkpatch and /dev/null differ
diff --git a/apk/external/out/.gitkeep b/apk/external/out/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/apk/external/patcher.py b/apk/external/patcher.py
deleted file mode 100755
index 2666e5eeb4..0000000000
--- a/apk/external/patcher.py
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/env python2.7
-
-import os
-import sys
-import glob
-import shutil
-import urllib2
-import hashlib
-import subprocess
-
-
-EXTERNAL_PATH = os.path.dirname(os.path.abspath(__file__))
-
-if os.path.exists("/init.qcom.rc"):
- # android
- APKPATCH = os.path.join(EXTERNAL_PATH, 'tools/apkpatch_android')
- SIGNAPK = os.path.join(EXTERNAL_PATH, 'tools/signapk_android')
-else:
- APKPATCH = os.path.join(EXTERNAL_PATH, 'tools/apkpatch')
- SIGNAPK = os.path.join(EXTERNAL_PATH, 'tools/signapk')
-
-APKS = {
- 'com.waze': {
- 'src': 'https://apkcache.s3.amazonaws.com/com.waze_1021278.apk',
- 'src_sha256': 'f00957e93e2389f9e30502ac54994b98ac769314b0963c263d4e8baa625ab0c2',
- 'patch': 'com.waze.apkpatch',
- 'out_sha256': 'fee880a91a44c738442cd05fd1b6d9b5817cbf755aa61c86325ada2bc443d5cf'
- },
- 'com.spotify.music': {
- 'src': 'https://apkcache.s3.amazonaws.com/com.spotify.music_24382006.apk',
- 'src_sha256': '0610fea68ee7ba5f8e4e0732ad429d729dd6cbb8bc21222c4c99db6cb09fbff4',
- 'patch': 'com.spotify.music.apkpatch',
- 'out_sha256': '5a3d6f478c7e40403a98ccc8906d7e0ae12b06543b41f5df52149dd09c647c11'
- },
-}
-
-def sha256_path(path):
- with open(path, 'rb') as f:
- return hashlib.sha256(f.read()).hexdigest()
-
-def remove(path):
- try:
- os.remove(path)
- except OSError:
- pass
-
-def process(download, patch):
- # clean up any junk apks
- for out_apk in glob.glob(os.path.join(EXTERNAL_PATH, 'out/*.apk')):
- app = os.path.basename(out_apk)[:-4]
- if app not in APKS:
- print "remove junk", out_apk
- remove(out_apk)
-
- complete = True
- for k,v in APKS.iteritems():
- apk_path = os.path.join(EXTERNAL_PATH, 'out', k+'.apk')
- print "checking", apk_path
- if os.path.exists(apk_path) and sha256_path(apk_path) == v['out_sha256']:
- # nothing to do
- continue
-
- complete = False
-
- remove(apk_path)
-
- src_path = os.path.join(EXTERNAL_PATH, 'src', v['src_sha256'])
- if not os.path.exists(src_path) or sha256_path(src_path) != v['src_sha256']:
- if not download:
- continue
-
- print "downloading", v['src'], "to", src_path
- # download it
- resp = urllib2.urlopen(v['src'])
- data = resp.read()
- with open(src_path, 'wb') as src_f:
- src_f.write(data)
-
- if sha256_path(src_path) != v['src_sha256']:
- print "download was corrupted..."
- continue
-
- if not patch:
- continue
-
- # ignoring lots of TOCTTOU here...
-
- apk_temp = "/tmp/"+k+".patched"
- remove(apk_temp)
- apk_temp2 = "/tmp/"+k+".signed"
- remove(apk_temp2)
-
- try:
- print "patching", v['patch']
- subprocess.check_call([APKPATCH, 'apply', src_path, apk_temp, os.path.join(EXTERNAL_PATH, v['patch'])])
- print "signing", apk_temp
- subprocess.check_call([SIGNAPK,
- os.path.join(EXTERNAL_PATH, 'tools/certificate.pem'), os.path.join(EXTERNAL_PATH, 'tools/key.pk8'),
- apk_temp, apk_temp2])
-
- out_sha256 = sha256_path(apk_temp2) if os.path.exists(apk_temp2) else None
-
- if out_sha256 == v['out_sha256']:
- print "done", apk_path
- shutil.move(apk_temp2, apk_path)
- else:
- print "patch was corrupted", apk_temp2, out_sha256
- finally:
- remove(apk_temp)
- remove(apk_temp2)
-
- return complete
-
-if __name__ == "__main__":
- ret = True
- if len(sys.argv) == 2 and sys.argv[1] == "download":
- ret = process(True, False)
- elif len(sys.argv) == 2 and sys.argv[1] == "patch":
- ret = process(False, True)
- else:
- ret = process(True, True)
- sys.exit(0 if ret else 1)
diff --git a/apk/external/src/.gitkeep b/apk/external/src/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/apk/external/tools/ApkPatch.android.jar b/apk/external/tools/ApkPatch.android.jar
deleted file mode 100644
index 3c8db3dc2f..0000000000
Binary files a/apk/external/tools/ApkPatch.android.jar and /dev/null differ
diff --git a/apk/external/tools/apkpatch_android b/apk/external/tools/apkpatch_android
deleted file mode 100755
index a3489202e7..0000000000
--- a/apk/external/tools/apkpatch_android
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/system/bin/sh
-
-DIR="$(cd "$(dirname "$0")" && pwd)"
-
-export LD_LIBRARY_PATH=/system/lib64
-export CLASSPATH="$DIR"/ApkPatch.android.jar
-exec app_process "$DIR" ApkPatch "$@"
diff --git a/apk/external/tools/certificate.pem b/apk/external/tools/certificate.pem
deleted file mode 100755
index 4d5c38a162..0000000000
--- a/apk/external/tools/certificate.pem
+++ /dev/null
@@ -1,17 +0,0 @@
------BEGIN CERTIFICATE-----
-MIICtTCCAh4CCQDm79UqF+Dc5zANBgkqhkiG9w0BAQUFADCBnjELMAkGA1UEBhMC
-SUQxEzARBgNVBAgTCkphd2EgQmFyYXQxEDAOBgNVBAcTB0JhbmR1bmcxEjAQBgNV
-BAoTCUxvbmRhdGlnYTETMBEGA1UECxMKQW5kcm9pZERldjEaMBgGA1UEAxMRTG9y
-ZW5zaXVzIFcuIEwuIFQxIzAhBgkqhkiG9w0BCQEWFGxvcmVuekBsb25kYXRpZ2Eu
-bmV0MB4XDTEwMDUwNTA5MjEzOFoXDTEzMDEyODA5MjEzOFowgZ4xCzAJBgNVBAYT
-AklEMRMwEQYDVQQIEwpKYXdhIEJhcmF0MRAwDgYDVQQHEwdCYW5kdW5nMRIwEAYD
-VQQKEwlMb25kYXRpZ2ExEzARBgNVBAsTCkFuZHJvaWREZXYxGjAYBgNVBAMTEUxv
-cmVuc2l1cyBXLiBMLiBUMSMwIQYJKoZIhvcNAQkBFhRsb3JlbnpAbG9uZGF0aWdh
-Lm5ldDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAy2oWtbdVXMHGiS6cA3qi
-3VfZt5Vz9jTlux+TEcGx5h18ZKwclyo+z2B0L/p5bYdnrTdFEiD7IxvX+h3lu0JV
-B9rdXZdyrzXNOw5YFrsn2k7hKvB8KEBaga1gZEwodlc6N14H3FbZdZkIA9V716Pu
-e5CWBZ2VqU03lUJmKnpH8c8CAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpNgXh8dw9
-uMjZxzLUXovV5ptHd61jAcZlQlffqPsz6/2QNfIShVdGH9jkm0IudfKkbvvOKive
-a77t9c4sDh2Sat2L/rx6BfTuS1+y9wFr1Ee8Rrr7wGHhRkx2qqGrXGVWqXn8aE3E
-P6e7BTPF0ibS+tG8cdDPEisqGFxw36nTNQ==
------END CERTIFICATE-----
diff --git a/apk/external/tools/key.pk8 b/apk/external/tools/key.pk8
deleted file mode 100755
index 1576cade82..0000000000
Binary files a/apk/external/tools/key.pk8 and /dev/null differ
diff --git a/apk/external/tools/signapk.android.jar b/apk/external/tools/signapk.android.jar
deleted file mode 100644
index f70218c0fc..0000000000
Binary files a/apk/external/tools/signapk.android.jar and /dev/null differ
diff --git a/apk/external/tools/signapk_android b/apk/external/tools/signapk_android
deleted file mode 100755
index f04898fe39..0000000000
--- a/apk/external/tools/signapk_android
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/system/bin/sh
-
-DIR="$(cd "$(dirname "$0")" && pwd)"
-
-export LD_LIBRARY_PATH=/system/lib64
-export CLASSPATH="$DIR"/signapk.android.jar
-exec app_process "$DIR" com.android.signapk.SignApk "$@"
diff --git a/cereal/car.capnp b/cereal/car.capnp
index b4c766651b..ffc79e6476 100644
--- a/cereal/car.capnp
+++ b/cereal/car.capnp
@@ -59,6 +59,10 @@ struct CarEvent @0x9b1657f34caf3ad3 {
debugAlert @34;
steerTempUnavailableMute @35;
resumeRequired @36;
+ preDriverDistracted @37;
+ promptDriverDistracted @38;
+ driverDistracted @39;
+ geofence @40;
}
}
@@ -333,7 +337,7 @@ struct CarParams {
directAccelControl @31 :Bool; # Does the car have direct accel control or just gas/brake
stoppingControl @34 :Bool; # Does the car allows full control even at lows speeds when stopping
startAccel @35 :Float32; # Required acceleraton to overcome creep braking
- steerRateCostDEPRECATED @40 :Float32; # Lateral MPC cost on steering rate
+ steerRateCost @40 :Float32; # Lateral MPC cost on steering rate
steerControlType @46 :SteerControlType;
radarOffCan @47 :Bool; # True when radar objects aren't visible on CAN
diff --git a/cereal/log.capnp b/cereal/log.capnp
index 84bf1b3b5e..474c0d2410 100644
--- a/cereal/log.capnp
+++ b/cereal/log.capnp
@@ -264,6 +264,15 @@ struct ThermalData {
fanSpeed @10 :UInt16;
started @11 :Bool;
startedTs @13 :UInt64;
+
+ thermalStatus @14 :ThermalStatus;
+
+ enum ThermalStatus {
+ green @0; # all processes run
+ yellow @1; # critical processes run (kill uploader), engage still allowed
+ red @2; # no engage, will disengage
+ danger @3; # immediate process shutdown
+ }
}
struct HealthData {
@@ -274,6 +283,7 @@ struct HealthData {
controlsAllowed @3 :Bool;
gasInterceptorDetected @4 :Bool;
startedSignalDetected @5 :Bool;
+ isGreyPanda @6 :Bool;
}
struct LiveUI {
@@ -384,11 +394,11 @@ struct Live100Data {
alertText2 @25 :Text;
alertStatus @38 :AlertStatus;
alertSize @39 :AlertSize;
+ alertBlinkingRate @42 :Float32;
awarenessStatus @26 :Float32;
-
angleOffset @27 :Float32;
-
gpsPlannerActive @40 :Bool;
+ engageable @41 :Bool; # can OP be engaged?
enum ControlState {
disabled @0;
@@ -591,6 +601,7 @@ struct LiveLocationData {
poseQuatECEF @19 :List(Float32);
pitchCalibration @20 :Float32;
yawCalibration @21 :Float32;
+ imuFrame @22 :List(Float32);
struct Accuracy {
pNEDError @0 :List(Float32);
@@ -1519,6 +1530,11 @@ struct OrbKeyFrame {
descriptors @3 :Data;
}
+struct DriverMonitoring {
+ frameId @0 :UInt32;
+ descriptor @1 :List(Float32);
+}
+
struct Event {
# in nanoseconds?
logMonoTime @0 :UInt64;
@@ -1582,5 +1598,6 @@ struct Event {
orbKeyFrame @56 :OrbKeyFrame;
uiLayoutState @57 :UiLayoutState;
orbFeaturesSummary @58 :OrbFeaturesSummary;
+ driverMonitoring @59 :DriverMonitoring;
}
}
diff --git a/common/fingerprints.py b/common/fingerprints.py
index 51d78a34c7..d4845f8d41 100644
--- a/common/fingerprints.py
+++ b/common/fingerprints.py
@@ -15,7 +15,7 @@ def get_fingerprint_list():
car_fingerprints = values.FINGERPRINTS
else:
continue
- for f, v in car_fingerprints.iteritems():
+ for f, v in car_fingerprints.items():
fingerprints[f] = v
except (ImportError, IOError):
pass
diff --git a/common/kalman/ekf.py b/common/kalman/ekf.py
index 4e9a97f9ad..fbed218f7a 100644
--- a/common/kalman/ekf.py
+++ b/common/kalman/ekf.py
@@ -1,4 +1,5 @@
# pylint: skip-file
+from __future__ import print_function
import abc
import numpy as np
# The EKF class contains the framework for an Extended Kalman Filter, but must be subclassed to use.
@@ -92,8 +93,8 @@ class EKF:
innovation = reading.data - reading.obs_model * self.state
if self.DEBUG:
- print "reading:\n",reading.data
- print "innovation:\n",innovation
+ print("reading:\n",reading.data)
+ print("innovation:\n",innovation)
# S = H*P*H' + R
innovation_covar = reading.obs_model * self.covar * reading.obs_model.T + reading.covar
@@ -103,12 +104,12 @@ class EKF:
innovation_covar)
if self.DEBUG:
- print "gain:\n", kalman_gain
- print "innovation_covar:\n", innovation_covar
- print "innovation: ", innovation
- print "test: ", self.covar * reading.obs_model.T * (
+ print("gain:\n", kalman_gain)
+ print("innovation_covar:\n", innovation_covar)
+ print("innovation: ", innovation)
+ print("test: ", self.covar * reading.obs_model.T * (
reading.obs_model * self.covar * reading.obs_model.T + reading.covar *
- 0).I
+ 0).I)
# x = x + K*y
self.state += kalman_gain*innovation
@@ -124,9 +125,9 @@ class EKF:
self.covar = aux_mtrx * self.covar * aux_mtrx.T + kalman_gain * reading.covar * kalman_gain.T
if self.DEBUG:
- print "After update"
- print "state\n", self.state
- print "covar:\n",self.covar
+ print("After update")
+ print("state\n", self.state)
+ print("covar:\n",self.covar)
def update_scalar(self, reading):
# like update but knowing that measurement is a scalar
diff --git a/common/logging_extra.py b/common/logging_extra.py
index bad9ad5165..43ae48882b 100644
--- a/common/logging_extra.py
+++ b/common/logging_extra.py
@@ -78,7 +78,7 @@ class SwagLogger(logging.Logger):
self.log_local = local()
self.log_local.ctx = {}
- def findCaller(self):
+ def findCaller(self, stack_info=None):
"""
Find the stack frame of the caller so that we can note the source
file name, line number and function name.
@@ -132,6 +132,9 @@ class SwagLogger(logging.Logger):
if args:
evt['args'] = args
evt.update(kwargs)
+ ctx = self.get_ctx()
+ if ctx:
+ evt['ctx'] = self.get_ctx()
if 'error' in kwargs:
self.error(evt)
else:
diff --git a/common/params.py b/common/params.py
index cd78dc3699..9d1b096af1 100755
--- a/common/params.py
+++ b/common/params.py
@@ -57,11 +57,12 @@ keys = {
# written: baseui
# read: ui, controls
"IsMetric": TxType.PERSISTENT,
- "IsRearViewMirror": TxType.PERSISTENT,
"IsFcwEnabled": TxType.PERSISTENT,
"HasAcceptedTerms": TxType.PERSISTENT,
"CompletedTrainingVersion": TxType.PERSISTENT,
"IsUploadVideoOverCellularEnabled": TxType.PERSISTENT,
+ "IsDriverMonitoringEnabled": TxType.PERSISTENT,
+ "IsGeofenceEnabled": TxType.PERSISTENT,
# written: visiond
# read: visiond, controlsd
"CalibrationParams": TxType.PERSISTENT,
@@ -315,7 +316,6 @@ class Params(object):
with self.env.begin(write=True) as txn:
txn.put(key, dat)
- print "set", key
if __name__ == "__main__":
params = Params()
@@ -325,11 +325,11 @@ if __name__ == "__main__":
for k in keys:
pp = params.get(k)
if pp is None:
- print k, "is None"
+ print("%s is None" % k)
elif all(ord(c) < 128 and ord(c) >= 32 for c in pp):
- print k, pp
+ print("%s = %s" % (k, pp))
else:
- print k, pp.encode("hex")
+ print("%s = %s" % (k, pp.encode("hex")))
# Test multiprocess:
# seq 0 100000 | xargs -P20 -I{} python common/params.py DongleId {} && sleep 0.05
diff --git a/common/profiler.py b/common/profiler.py
index 953f5737d8..7f9b1a41ff 100644
--- a/common/profiler.py
+++ b/common/profiler.py
@@ -36,11 +36,11 @@ class Profiler(object):
if not self.enabled:
return
self.iter += 1
- print "******* Profiling *******"
+ print("******* Profiling *******")
for n, ms in sorted(self.cp.items(), key=lambda x: -x[1]):
if n in self.cp_ignored:
- print "%30s: %7.2f percent: %3.0f" % (n, ms*1000.0, ms/self.tot*100), " IGNORED"
+ print("%30s: %7.2f percent: %3.0f IGNORED" % (n, ms*1000.0, ms/self.tot*100))
else:
- print "%30s: %7.2f percent: %3.0f" % (n, ms*1000.0, ms/self.tot*100)
- print "Iter clock: %2.6f TOTAL: %2.2f" % (self.tot/self.iter, self.tot)
+ print("%30s: %7.2f percent: %3.0f" % (n, ms*1000.0, ms/self.tot*100))
+ print("Iter clock: %2.6f TOTAL: %2.2f" % (self.tot/self.iter, self.tot))
diff --git a/common/realtime.py b/common/realtime.py
index b8d75db09e..7fe183fb23 100644
--- a/common/realtime.py
+++ b/common/realtime.py
@@ -106,5 +106,3 @@ class Ratekeeper(object):
self._remaining = remaining
return lagged
-if __name__ == "__main__":
- print sec_since_boot()
diff --git a/phonelibs/libgralloc/include/gralloc_priv.h b/phonelibs/libgralloc/include/gralloc_priv.h
new file mode 100644
index 0000000000..4aa47541b0
--- /dev/null
+++ b/phonelibs/libgralloc/include/gralloc_priv.h
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef GRALLOC_PRIV_H_
+#define GRALLOC_PRIV_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+
+#define ROUND_UP_PAGESIZE(x) ( (((unsigned long)(x)) + PAGE_SIZE-1) & \
+ (~(PAGE_SIZE-1)) )
+
+/* Gralloc usage bits indicating the type of allocation that should be used */
+/* SYSTEM heap comes from kernel vmalloc (ION_SYSTEM_HEAP_ID)
+ * is cached by default and
+ * is not secured */
+
+/* GRALLOC_USAGE_PRIVATE_0 is unused */
+
+/* Non linear, Universal Bandwidth Compression */
+#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_1
+
+/* IOMMU heap comes from manually allocated pages, can be cached/uncached,
+ * is not secured */
+#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP GRALLOC_USAGE_PRIVATE_2
+
+/* MM heap is a carveout heap for video, can be secured */
+#define GRALLOC_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_3
+
+/* ADSP heap is a carveout heap, is not secured */
+#define GRALLOC_USAGE_PRIVATE_ADSP_HEAP 0x01000000
+
+/* Set this for allocating uncached memory (using O_DSYNC),
+ * cannot be used with noncontiguous heaps */
+#define GRALLOC_USAGE_PRIVATE_UNCACHED 0x02000000
+
+/* Buffer content should be displayed on an primary display only */
+#define GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY 0x04000000
+
+/* Buffer content should be displayed on an external display only */
+#define GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY 0x08000000
+
+/* This flag is set for WFD usecase */
+#define GRALLOC_USAGE_PRIVATE_WFD 0x00200000
+
+/* CAMERA heap is a carveout heap for camera, is not secured */
+#define GRALLOC_USAGE_PRIVATE_CAMERA_HEAP 0x00400000
+
+/* This flag is used for SECURE display usecase */
+#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY 0x00800000
+
+/* define Gralloc perform */
+#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1
+// This will be used by the graphics drivers to know if certain features
+// are defined in this display HAL.
+// Ex: Newer GFX libraries + Older Display HAL
+#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2
+#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3
+#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4
+#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5
+#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6
+#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7
+#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8
+#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9
+#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10
+#define GRALLOC_MODULE_PERFORM_GET_IGC 11
+#define GRALLOC_MODULE_PERFORM_SET_IGC 12
+#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13
+
+/* OEM specific HAL formats */
+
+#define HAL_PIXEL_FORMAT_RGBA_5551 6
+#define HAL_PIXEL_FORMAT_RGBA_4444 7
+#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109
+#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01
+#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B
+#define HAL_PIXEL_FORMAT_R_8 0x10D
+#define HAL_PIXEL_FORMAT_RG_88 0x10E
+#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F
+#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110
+#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111
+#define HAL_PIXEL_FORMAT_BGRX_8888 0x112
+#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113
+#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114
+#define HAL_PIXEL_FORMAT_BGR_565 0x115
+#define HAL_PIXEL_FORMAT_INTERLACE 0x180
+
+//v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component
+#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559
+
+//v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed
+//format reduces the memory access bandwidth
+#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259
+
+// UBWC aligned Venus format
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06
+
+//Khronos ASTC formats
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+
+/* possible values for inverse gamma correction */
+#define HAL_IGC_NOT_SPECIFIED 0
+#define HAL_IGC_s_RGB 1
+
+/* possible formats for 3D content*/
+enum {
+ HAL_NO_3D = 0x0,
+ HAL_3D_SIDE_BY_SIDE_L_R = 0x1,
+ HAL_3D_SIDE_BY_SIDE_R_L = 0x2,
+ HAL_3D_TOP_BOTTOM = 0x4,
+ HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, //unused legacy format
+};
+
+enum {
+ BUFFER_TYPE_UI = 0,
+ BUFFER_TYPE_VIDEO
+};
+
+#ifdef __cplusplus
+struct private_handle_t : public native_handle {
+#else
+ struct private_handle_t {
+ native_handle_t nativeHandle;
+#endif
+ enum {
+ PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
+ PRIV_FLAGS_USES_ION = 0x00000008,
+ PRIV_FLAGS_USES_ASHMEM = 0x00000010,
+ PRIV_FLAGS_NEEDS_FLUSH = 0x00000020,
+ PRIV_FLAGS_INTERNAL_ONLY = 0x00000040,
+ PRIV_FLAGS_NON_CPU_WRITER = 0x00000080,
+ PRIV_FLAGS_NONCONTIGUOUS_MEM = 0x00000100,
+ PRIV_FLAGS_CACHED = 0x00000200,
+ PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
+ // Display on external only
+ PRIV_FLAGS_EXTERNAL_ONLY = 0x00002000,
+ // Set by HWC for protected non secure buffers
+ PRIV_FLAGS_PROTECTED_BUFFER = 0x00004000,
+ PRIV_FLAGS_VIDEO_ENCODER = 0x00010000,
+ PRIV_FLAGS_CAMERA_WRITE = 0x00020000,
+ PRIV_FLAGS_CAMERA_READ = 0x00040000,
+ PRIV_FLAGS_HW_COMPOSER = 0x00080000,
+ PRIV_FLAGS_HW_TEXTURE = 0x00100000,
+ PRIV_FLAGS_ITU_R_601 = 0x00200000, //Unused from display
+ PRIV_FLAGS_ITU_R_601_FR = 0x00400000, //Unused from display
+ PRIV_FLAGS_ITU_R_709 = 0x00800000, //Unused from display
+ PRIV_FLAGS_SECURE_DISPLAY = 0x01000000,
+ // Buffer is rendered in Tile Format
+ PRIV_FLAGS_TILE_RENDERED = 0x02000000,
+ // Buffer rendered using CPU/SW renderer
+ PRIV_FLAGS_CPU_RENDERED = 0x04000000,
+ // Buffer is allocated with UBWC alignment
+ PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
+ // Buffer allocated will be consumed by SF/HWC
+ PRIV_FLAGS_DISP_CONSUMER = 0x10000000
+ };
+
+ // file-descriptors
+ int fd;
+ int fd_metadata; // fd for the meta-data
+ // ints
+ int magic;
+ int flags;
+ unsigned int size;
+ unsigned int offset;
+ int bufferType;
+ uint64_t base __attribute__((aligned(8)));
+ unsigned int offset_metadata;
+ // The gpu address mapped into the mmu.
+ uint64_t gpuaddr __attribute__((aligned(8)));
+ int format;
+ int width; // specifies aligned width
+ int height; // specifies aligned height
+ int real_width;
+ int real_height;
+ uint64_t base_metadata __attribute__((aligned(8)));
+
+#ifdef __cplusplus
+ static const int sNumFds = 2;
+ static inline int sNumInts() {
+ return ((sizeof(private_handle_t) - sizeof(native_handle_t)) /
+ sizeof(int)) - sNumFds;
+ }
+ static const int sMagic = 'gmsm';
+
+ private_handle_t(int fd, unsigned int size, int flags, int bufferType,
+ int format, int aligned_width, int aligned_height,
+ int width, int height, int eFd = -1,
+ unsigned int eOffset = 0, uint64_t eBase = 0) :
+ fd(fd), fd_metadata(eFd), magic(sMagic),
+ flags(flags), size(size), offset(0), bufferType(bufferType),
+ base(0), offset_metadata(eOffset), gpuaddr(0),
+ format(format), width(aligned_width), height(aligned_height),
+ real_width(width), real_height(height), base_metadata(eBase)
+ {
+ version = (int) sizeof(native_handle);
+ numInts = sNumInts();
+ numFds = sNumFds;
+ }
+ ~private_handle_t() {
+ magic = 0;
+ }
+
+ static int validate(const native_handle* h) {
+ const private_handle_t* hnd = (const private_handle_t*)h;
+ if (!h || h->version != sizeof(native_handle) ||
+ h->numInts != sNumInts() || h->numFds != sNumFds ||
+ hnd->magic != sMagic)
+ {
+ ALOGD("Invalid gralloc handle (at %p): "
+ "ver(%d/%zu) ints(%d/%d) fds(%d/%d)"
+ "magic(%c%c%c%c/%c%c%c%c)",
+ h,
+ h ? h->version : -1, sizeof(native_handle),
+ h ? h->numInts : -1, sNumInts(),
+ h ? h->numFds : -1, sNumFds,
+ hnd ? (((hnd->magic >> 24) & 0xFF)?
+ ((hnd->magic >> 24) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 16) & 0xFF)?
+ ((hnd->magic >> 16) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 8) & 0xFF)?
+ ((hnd->magic >> 8) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 0) & 0xFF)?
+ ((hnd->magic >> 0) & 0xFF) : '-') : '?',
+ (sMagic >> 24) & 0xFF,
+ (sMagic >> 16) & 0xFF,
+ (sMagic >> 8) & 0xFF,
+ (sMagic >> 0) & 0xFF);
+ return -EINVAL;
+ }
+ return 0;
+ }
+
+ static private_handle_t* dynamicCast(const native_handle* in) {
+ if (validate(in) == 0) {
+ return (private_handle_t*) in;
+ }
+ return NULL;
+ }
+#endif
+ };
+
+#endif /* GRALLOC_PRIV_H_ */
diff --git a/phonelibs/linux/include/msm_ion.h b/phonelibs/linux/include/msm_ion.h
new file mode 100644
index 0000000000..e41b3170fd
--- /dev/null
+++ b/phonelibs/linux/include/msm_ion.h
@@ -0,0 +1,211 @@
+#ifndef _UAPI_MSM_ION_H
+#define _UAPI_MSM_ION_H
+
+#include
+
+enum msm_ion_heap_types {
+ ION_HEAP_TYPE_MSM_START = ION_HEAP_TYPE_CUSTOM + 1,
+ ION_HEAP_TYPE_SECURE_DMA = ION_HEAP_TYPE_MSM_START,
+ ION_HEAP_TYPE_SYSTEM_SECURE,
+ ION_HEAP_TYPE_HYP_CMA,
+ /*
+ * if you add a heap type here you should also add it to
+ * heap_types_info[] in msm_ion.c
+ */
+};
+
+/**
+ * These are the only ids that should be used for Ion heap ids.
+ * The ids listed are the order in which allocation will be attempted
+ * if specified. Don't swap the order of heap ids unless you know what
+ * you are doing!
+ * Id's are spaced by purpose to allow new Id's to be inserted in-between (for
+ * possible fallbacks)
+ */
+
+enum ion_heap_ids {
+ INVALID_HEAP_ID = -1,
+ ION_CP_MM_HEAP_ID = 8,
+ ION_SECURE_HEAP_ID = 9,
+ ION_SECURE_DISPLAY_HEAP_ID = 10,
+ ION_CP_MFC_HEAP_ID = 12,
+ ION_CP_WB_HEAP_ID = 16, /* 8660 only */
+ ION_CAMERA_HEAP_ID = 20, /* 8660 only */
+ ION_SYSTEM_CONTIG_HEAP_ID = 21,
+ ION_ADSP_HEAP_ID = 22,
+ ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */
+ ION_SF_HEAP_ID = 24,
+ ION_SYSTEM_HEAP_ID = 25,
+ ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */
+ ION_QSECOM_HEAP_ID = 27,
+ ION_AUDIO_HEAP_ID = 28,
+
+ ION_MM_FIRMWARE_HEAP_ID = 29,
+
+ ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */
+};
+
+/*
+ * The IOMMU heap is deprecated! Here are some aliases for backwards
+ * compatibility:
+ */
+#define ION_IOMMU_HEAP_ID ION_SYSTEM_HEAP_ID
+#define ION_HEAP_TYPE_IOMMU ION_HEAP_TYPE_SYSTEM
+
+enum ion_fixed_position {
+ NOT_FIXED,
+ FIXED_LOW,
+ FIXED_MIDDLE,
+ FIXED_HIGH,
+};
+
+enum cp_mem_usage {
+ VIDEO_BITSTREAM = 0x1,
+ VIDEO_PIXEL = 0x2,
+ VIDEO_NONPIXEL = 0x3,
+ DISPLAY_SECURE_CP_USAGE = 0x4,
+ CAMERA_SECURE_CP_USAGE = 0x5,
+ MAX_USAGE = 0x6,
+ UNKNOWN = 0x7FFFFFFF,
+};
+
+/**
+ * Flags to be used when allocating from the secure heap for
+ * content protection
+ */
+#define ION_FLAG_CP_TOUCH (1 << 17)
+#define ION_FLAG_CP_BITSTREAM (1 << 18)
+#define ION_FLAG_CP_PIXEL (1 << 19)
+#define ION_FLAG_CP_NON_PIXEL (1 << 20)
+#define ION_FLAG_CP_CAMERA (1 << 21)
+#define ION_FLAG_CP_HLOS (1 << 22)
+#define ION_FLAG_CP_HLOS_FREE (1 << 23)
+#define ION_FLAG_CP_SEC_DISPLAY (1 << 25)
+#define ION_FLAG_CP_APP (1 << 26)
+
+/**
+ * Flag to allow non continguous allocation of memory from secure
+ * heap
+ */
+#define ION_FLAG_ALLOW_NON_CONTIG (1 << 24)
+
+/**
+ * Flag to use when allocating to indicate that a heap is secure.
+ */
+#define ION_FLAG_SECURE (1 << ION_HEAP_ID_RESERVED)
+
+/**
+ * Flag for clients to force contiguous memort allocation
+ *
+ * Use of this flag is carefully monitored!
+ */
+#define ION_FLAG_FORCE_CONTIGUOUS (1 << 30)
+
+/*
+ * Used in conjunction with heap which pool memory to force an allocation
+ * to come from the page allocator directly instead of from the pool allocation
+ */
+#define ION_FLAG_POOL_FORCE_ALLOC (1 << 16)
+
+
+#define ION_FLAG_POOL_PREFETCH (1 << 27)
+
+/**
+* Deprecated! Please use the corresponding ION_FLAG_*
+*/
+#define ION_SECURE ION_FLAG_SECURE
+#define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS
+
+/**
+ * Macro should be used with ion_heap_ids defined above.
+ */
+#define ION_HEAP(bit) (1 << (bit))
+
+#define ION_ADSP_HEAP_NAME "adsp"
+#define ION_SYSTEM_HEAP_NAME "system"
+#define ION_VMALLOC_HEAP_NAME ION_SYSTEM_HEAP_NAME
+#define ION_KMALLOC_HEAP_NAME "kmalloc"
+#define ION_AUDIO_HEAP_NAME "audio"
+#define ION_SF_HEAP_NAME "sf"
+#define ION_MM_HEAP_NAME "mm"
+#define ION_CAMERA_HEAP_NAME "camera_preview"
+#define ION_IOMMU_HEAP_NAME "iommu"
+#define ION_MFC_HEAP_NAME "mfc"
+#define ION_WB_HEAP_NAME "wb"
+#define ION_MM_FIRMWARE_HEAP_NAME "mm_fw"
+#define ION_PIL1_HEAP_NAME "pil_1"
+#define ION_PIL2_HEAP_NAME "pil_2"
+#define ION_QSECOM_HEAP_NAME "qsecom"
+#define ION_SECURE_HEAP_NAME "secure_heap"
+#define ION_SECURE_DISPLAY_HEAP_NAME "secure_display"
+
+#define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED)
+#define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED)
+
+#define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED)
+
+/* struct ion_flush_data - data passed to ion for flushing caches
+ *
+ * @handle: handle with data to flush
+ * @fd: fd to flush
+ * @vaddr: userspace virtual address mapped with mmap
+ * @offset: offset into the handle to flush
+ * @length: length of handle to flush
+ *
+ * Performs cache operations on the handle. If p is the start address
+ * of the handle, p + offset through p + offset + length will have
+ * the cache operations performed
+ */
+struct ion_flush_data {
+ ion_user_handle_t handle;
+ int fd;
+ void *vaddr;
+ unsigned int offset;
+ unsigned int length;
+};
+
+struct ion_prefetch_regions {
+ unsigned int vmid;
+ size_t __user *sizes;
+ unsigned int nr_sizes;
+};
+
+struct ion_prefetch_data {
+ int heap_id;
+ unsigned long len;
+ /* Is unsigned long bad? 32bit compiler vs 64 bit compiler*/
+ struct ion_prefetch_regions __user *regions;
+ unsigned int nr_regions;
+};
+
+#define ION_IOC_MSM_MAGIC 'M'
+
+/**
+ * DOC: ION_IOC_CLEAN_CACHES - clean the caches
+ *
+ * Clean the caches of the handle specified.
+ */
+#define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \
+ struct ion_flush_data)
+/**
+ * DOC: ION_IOC_INV_CACHES - invalidate the caches
+ *
+ * Invalidate the caches of the handle specified.
+ */
+#define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \
+ struct ion_flush_data)
+/**
+ * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches
+ *
+ * Clean and invalidate the caches of the handle specified.
+ */
+#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \
+ struct ion_flush_data)
+
+#define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \
+ struct ion_prefetch_data)
+
+#define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \
+ struct ion_prefetch_data)
+
+#endif
diff --git a/phonelibs/opencl/include/CL/cl.h b/phonelibs/opencl/include/CL/cl.h
new file mode 100644
index 0000000000..0086319f5f
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl.h
@@ -0,0 +1,1452 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+#ifndef __OPENCL_CL_H
+#define __OPENCL_CL_H
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************/
+
+typedef struct _cl_platform_id * cl_platform_id;
+typedef struct _cl_device_id * cl_device_id;
+typedef struct _cl_context * cl_context;
+typedef struct _cl_command_queue * cl_command_queue;
+typedef struct _cl_mem * cl_mem;
+typedef struct _cl_program * cl_program;
+typedef struct _cl_kernel * cl_kernel;
+typedef struct _cl_event * cl_event;
+typedef struct _cl_sampler * cl_sampler;
+
+typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
+typedef cl_ulong cl_bitfield;
+typedef cl_bitfield cl_device_type;
+typedef cl_uint cl_platform_info;
+typedef cl_uint cl_device_info;
+typedef cl_bitfield cl_device_fp_config;
+typedef cl_uint cl_device_mem_cache_type;
+typedef cl_uint cl_device_local_mem_type;
+typedef cl_bitfield cl_device_exec_capabilities;
+typedef cl_bitfield cl_device_svm_capabilities;
+typedef cl_bitfield cl_command_queue_properties;
+typedef intptr_t cl_device_partition_property;
+typedef cl_bitfield cl_device_affinity_domain;
+
+typedef intptr_t cl_context_properties;
+typedef cl_uint cl_context_info;
+typedef cl_bitfield cl_queue_properties;
+typedef cl_uint cl_command_queue_info;
+typedef cl_uint cl_channel_order;
+typedef cl_uint cl_channel_type;
+typedef cl_bitfield cl_mem_flags;
+typedef cl_bitfield cl_svm_mem_flags;
+typedef cl_uint cl_mem_object_type;
+typedef cl_uint cl_mem_info;
+typedef cl_bitfield cl_mem_migration_flags;
+typedef cl_uint cl_image_info;
+typedef cl_uint cl_buffer_create_type;
+typedef cl_uint cl_addressing_mode;
+typedef cl_uint cl_filter_mode;
+typedef cl_uint cl_sampler_info;
+typedef cl_bitfield cl_map_flags;
+typedef intptr_t cl_pipe_properties;
+typedef cl_uint cl_pipe_info;
+typedef cl_uint cl_program_info;
+typedef cl_uint cl_program_build_info;
+typedef cl_uint cl_program_binary_type;
+typedef cl_int cl_build_status;
+typedef cl_uint cl_kernel_info;
+typedef cl_uint cl_kernel_arg_info;
+typedef cl_uint cl_kernel_arg_address_qualifier;
+typedef cl_uint cl_kernel_arg_access_qualifier;
+typedef cl_bitfield cl_kernel_arg_type_qualifier;
+typedef cl_uint cl_kernel_work_group_info;
+typedef cl_uint cl_kernel_sub_group_info;
+typedef cl_uint cl_event_info;
+typedef cl_uint cl_command_type;
+typedef cl_uint cl_profiling_info;
+typedef cl_bitfield cl_sampler_properties;
+typedef cl_uint cl_kernel_exec_info;
+
+typedef struct _cl_image_format {
+ cl_channel_order image_channel_order;
+ cl_channel_type image_channel_data_type;
+} cl_image_format;
+
+typedef struct _cl_image_desc {
+ cl_mem_object_type image_type;
+ size_t image_width;
+ size_t image_height;
+ size_t image_depth;
+ size_t image_array_size;
+ size_t image_row_pitch;
+ size_t image_slice_pitch;
+ cl_uint num_mip_levels;
+ cl_uint num_samples;
+#ifdef __GNUC__
+ __extension__ /* Prevents warnings about anonymous union in -pedantic builds */
+#endif
+ union {
+ cl_mem buffer;
+ cl_mem mem_object;
+ };
+} cl_image_desc;
+
+typedef struct _cl_buffer_region {
+ size_t origin;
+ size_t size;
+} cl_buffer_region;
+
+
+/******************************************************************************/
+
+/* Error Codes */
+#define CL_SUCCESS 0
+#define CL_DEVICE_NOT_FOUND -1
+#define CL_DEVICE_NOT_AVAILABLE -2
+#define CL_COMPILER_NOT_AVAILABLE -3
+#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
+#define CL_OUT_OF_RESOURCES -5
+#define CL_OUT_OF_HOST_MEMORY -6
+#define CL_PROFILING_INFO_NOT_AVAILABLE -7
+#define CL_MEM_COPY_OVERLAP -8
+#define CL_IMAGE_FORMAT_MISMATCH -9
+#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
+#define CL_BUILD_PROGRAM_FAILURE -11
+#define CL_MAP_FAILURE -12
+#define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
+#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
+#define CL_COMPILE_PROGRAM_FAILURE -15
+#define CL_LINKER_NOT_AVAILABLE -16
+#define CL_LINK_PROGRAM_FAILURE -17
+#define CL_DEVICE_PARTITION_FAILED -18
+#define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19
+
+#define CL_INVALID_VALUE -30
+#define CL_INVALID_DEVICE_TYPE -31
+#define CL_INVALID_PLATFORM -32
+#define CL_INVALID_DEVICE -33
+#define CL_INVALID_CONTEXT -34
+#define CL_INVALID_QUEUE_PROPERTIES -35
+#define CL_INVALID_COMMAND_QUEUE -36
+#define CL_INVALID_HOST_PTR -37
+#define CL_INVALID_MEM_OBJECT -38
+#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
+#define CL_INVALID_IMAGE_SIZE -40
+#define CL_INVALID_SAMPLER -41
+#define CL_INVALID_BINARY -42
+#define CL_INVALID_BUILD_OPTIONS -43
+#define CL_INVALID_PROGRAM -44
+#define CL_INVALID_PROGRAM_EXECUTABLE -45
+#define CL_INVALID_KERNEL_NAME -46
+#define CL_INVALID_KERNEL_DEFINITION -47
+#define CL_INVALID_KERNEL -48
+#define CL_INVALID_ARG_INDEX -49
+#define CL_INVALID_ARG_VALUE -50
+#define CL_INVALID_ARG_SIZE -51
+#define CL_INVALID_KERNEL_ARGS -52
+#define CL_INVALID_WORK_DIMENSION -53
+#define CL_INVALID_WORK_GROUP_SIZE -54
+#define CL_INVALID_WORK_ITEM_SIZE -55
+#define CL_INVALID_GLOBAL_OFFSET -56
+#define CL_INVALID_EVENT_WAIT_LIST -57
+#define CL_INVALID_EVENT -58
+#define CL_INVALID_OPERATION -59
+#define CL_INVALID_GL_OBJECT -60
+#define CL_INVALID_BUFFER_SIZE -61
+#define CL_INVALID_MIP_LEVEL -62
+#define CL_INVALID_GLOBAL_WORK_SIZE -63
+#define CL_INVALID_PROPERTY -64
+#define CL_INVALID_IMAGE_DESCRIPTOR -65
+#define CL_INVALID_COMPILER_OPTIONS -66
+#define CL_INVALID_LINKER_OPTIONS -67
+#define CL_INVALID_DEVICE_PARTITION_COUNT -68
+#define CL_INVALID_PIPE_SIZE -69
+#define CL_INVALID_DEVICE_QUEUE -70
+
+/* OpenCL Version */
+#define CL_VERSION_1_0 1
+#define CL_VERSION_1_1 1
+#define CL_VERSION_1_2 1
+#define CL_VERSION_2_0 1
+#define CL_VERSION_2_1 1
+
+/* cl_bool */
+#define CL_FALSE 0
+#define CL_TRUE 1
+#define CL_BLOCKING CL_TRUE
+#define CL_NON_BLOCKING CL_FALSE
+
+/* cl_platform_info */
+#define CL_PLATFORM_PROFILE 0x0900
+#define CL_PLATFORM_VERSION 0x0901
+#define CL_PLATFORM_NAME 0x0902
+#define CL_PLATFORM_VENDOR 0x0903
+#define CL_PLATFORM_EXTENSIONS 0x0904
+#define CL_PLATFORM_HOST_TIMER_RESOLUTION 0x0905
+
+/* cl_device_type - bitfield */
+#define CL_DEVICE_TYPE_DEFAULT (1 << 0)
+#define CL_DEVICE_TYPE_CPU (1 << 1)
+#define CL_DEVICE_TYPE_GPU (1 << 2)
+#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
+#define CL_DEVICE_TYPE_CUSTOM (1 << 4)
+#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
+
+/* cl_device_info */
+#define CL_DEVICE_TYPE 0x1000
+#define CL_DEVICE_VENDOR_ID 0x1001
+#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
+#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
+#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
+#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
+#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
+#define CL_DEVICE_ADDRESS_BITS 0x100D
+#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
+#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
+#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
+#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
+#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
+#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
+#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
+#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
+#define CL_DEVICE_IMAGE_SUPPORT 0x1016
+#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
+#define CL_DEVICE_MAX_SAMPLERS 0x1018
+#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
+#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
+#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
+#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
+#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
+#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
+#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
+#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
+#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
+#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
+#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
+#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
+#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
+#define CL_DEVICE_ENDIAN_LITTLE 0x1026
+#define CL_DEVICE_AVAILABLE 0x1027
+#define CL_DEVICE_COMPILER_AVAILABLE 0x1028
+#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
+#define CL_DEVICE_QUEUE_PROPERTIES 0x102A /* deprecated */
+#define CL_DEVICE_QUEUE_ON_HOST_PROPERTIES 0x102A
+#define CL_DEVICE_NAME 0x102B
+#define CL_DEVICE_VENDOR 0x102C
+#define CL_DRIVER_VERSION 0x102D
+#define CL_DEVICE_PROFILE 0x102E
+#define CL_DEVICE_VERSION 0x102F
+#define CL_DEVICE_EXTENSIONS 0x1030
+#define CL_DEVICE_PLATFORM 0x1031
+#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
+/* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034
+#define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035 /* deprecated */
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C
+#define CL_DEVICE_OPENCL_C_VERSION 0x103D
+#define CL_DEVICE_LINKER_AVAILABLE 0x103E
+#define CL_DEVICE_BUILT_IN_KERNELS 0x103F
+#define CL_DEVICE_IMAGE_MAX_BUFFER_SIZE 0x1040
+#define CL_DEVICE_IMAGE_MAX_ARRAY_SIZE 0x1041
+#define CL_DEVICE_PARENT_DEVICE 0x1042
+#define CL_DEVICE_PARTITION_MAX_SUB_DEVICES 0x1043
+#define CL_DEVICE_PARTITION_PROPERTIES 0x1044
+#define CL_DEVICE_PARTITION_AFFINITY_DOMAIN 0x1045
+#define CL_DEVICE_PARTITION_TYPE 0x1046
+#define CL_DEVICE_REFERENCE_COUNT 0x1047
+#define CL_DEVICE_PREFERRED_INTEROP_USER_SYNC 0x1048
+#define CL_DEVICE_PRINTF_BUFFER_SIZE 0x1049
+#define CL_DEVICE_IMAGE_PITCH_ALIGNMENT 0x104A
+#define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT 0x104B
+#define CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS 0x104C
+#define CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE 0x104D
+#define CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES 0x104E
+#define CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE 0x104F
+#define CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE 0x1050
+#define CL_DEVICE_MAX_ON_DEVICE_QUEUES 0x1051
+#define CL_DEVICE_MAX_ON_DEVICE_EVENTS 0x1052
+#define CL_DEVICE_SVM_CAPABILITIES 0x1053
+#define CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE 0x1054
+#define CL_DEVICE_MAX_PIPE_ARGS 0x1055
+#define CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS 0x1056
+#define CL_DEVICE_PIPE_MAX_PACKET_SIZE 0x1057
+#define CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT 0x1058
+#define CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT 0x1059
+#define CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT 0x105A
+#define CL_DEVICE_IL_VERSION 0x105B
+#define CL_DEVICE_MAX_NUM_SUB_GROUPS 0x105C
+#define CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS 0x105D
+
+/* cl_device_fp_config - bitfield */
+#define CL_FP_DENORM (1 << 0)
+#define CL_FP_INF_NAN (1 << 1)
+#define CL_FP_ROUND_TO_NEAREST (1 << 2)
+#define CL_FP_ROUND_TO_ZERO (1 << 3)
+#define CL_FP_ROUND_TO_INF (1 << 4)
+#define CL_FP_FMA (1 << 5)
+#define CL_FP_SOFT_FLOAT (1 << 6)
+#define CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT (1 << 7)
+
+/* cl_device_mem_cache_type */
+#define CL_NONE 0x0
+#define CL_READ_ONLY_CACHE 0x1
+#define CL_READ_WRITE_CACHE 0x2
+
+/* cl_device_local_mem_type */
+#define CL_LOCAL 0x1
+#define CL_GLOBAL 0x2
+
+/* cl_device_exec_capabilities - bitfield */
+#define CL_EXEC_KERNEL (1 << 0)
+#define CL_EXEC_NATIVE_KERNEL (1 << 1)
+
+/* cl_command_queue_properties - bitfield */
+#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
+#define CL_QUEUE_PROFILING_ENABLE (1 << 1)
+#define CL_QUEUE_ON_DEVICE (1 << 2)
+#define CL_QUEUE_ON_DEVICE_DEFAULT (1 << 3)
+
+/* cl_context_info */
+#define CL_CONTEXT_REFERENCE_COUNT 0x1080
+#define CL_CONTEXT_DEVICES 0x1081
+#define CL_CONTEXT_PROPERTIES 0x1082
+#define CL_CONTEXT_NUM_DEVICES 0x1083
+
+/* cl_context_properties */
+#define CL_CONTEXT_PLATFORM 0x1084
+#define CL_CONTEXT_INTEROP_USER_SYNC 0x1085
+
+/* cl_device_partition_property */
+#define CL_DEVICE_PARTITION_EQUALLY 0x1086
+#define CL_DEVICE_PARTITION_BY_COUNTS 0x1087
+#define CL_DEVICE_PARTITION_BY_COUNTS_LIST_END 0x0
+#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN 0x1088
+
+/* cl_device_affinity_domain */
+#define CL_DEVICE_AFFINITY_DOMAIN_NUMA (1 << 0)
+#define CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE (1 << 1)
+#define CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE (1 << 2)
+#define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3)
+#define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4)
+#define CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE (1 << 5)
+
+/* cl_device_svm_capabilities */
+#define CL_DEVICE_SVM_COARSE_GRAIN_BUFFER (1 << 0)
+#define CL_DEVICE_SVM_FINE_GRAIN_BUFFER (1 << 1)
+#define CL_DEVICE_SVM_FINE_GRAIN_SYSTEM (1 << 2)
+#define CL_DEVICE_SVM_ATOMICS (1 << 3)
+
+/* cl_command_queue_info */
+#define CL_QUEUE_CONTEXT 0x1090
+#define CL_QUEUE_DEVICE 0x1091
+#define CL_QUEUE_REFERENCE_COUNT 0x1092
+#define CL_QUEUE_PROPERTIES 0x1093
+#define CL_QUEUE_SIZE 0x1094
+#define CL_QUEUE_DEVICE_DEFAULT 0x1095
+
+/* cl_mem_flags and cl_svm_mem_flags - bitfield */
+#define CL_MEM_READ_WRITE (1 << 0)
+#define CL_MEM_WRITE_ONLY (1 << 1)
+#define CL_MEM_READ_ONLY (1 << 2)
+#define CL_MEM_USE_HOST_PTR (1 << 3)
+#define CL_MEM_ALLOC_HOST_PTR (1 << 4)
+#define CL_MEM_COPY_HOST_PTR (1 << 5)
+/* reserved (1 << 6) */
+#define CL_MEM_HOST_WRITE_ONLY (1 << 7)
+#define CL_MEM_HOST_READ_ONLY (1 << 8)
+#define CL_MEM_HOST_NO_ACCESS (1 << 9)
+#define CL_MEM_SVM_FINE_GRAIN_BUFFER (1 << 10) /* used by cl_svm_mem_flags only */
+#define CL_MEM_SVM_ATOMICS (1 << 11) /* used by cl_svm_mem_flags only */
+#define CL_MEM_KERNEL_READ_AND_WRITE (1 << 12)
+
+/* cl_mem_migration_flags - bitfield */
+#define CL_MIGRATE_MEM_OBJECT_HOST (1 << 0)
+#define CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED (1 << 1)
+
+/* cl_channel_order */
+#define CL_R 0x10B0
+#define CL_A 0x10B1
+#define CL_RG 0x10B2
+#define CL_RA 0x10B3
+#define CL_RGB 0x10B4
+#define CL_RGBA 0x10B5
+#define CL_BGRA 0x10B6
+#define CL_ARGB 0x10B7
+#define CL_INTENSITY 0x10B8
+#define CL_LUMINANCE 0x10B9
+#define CL_Rx 0x10BA
+#define CL_RGx 0x10BB
+#define CL_RGBx 0x10BC
+#define CL_DEPTH 0x10BD
+#define CL_DEPTH_STENCIL 0x10BE
+#define CL_sRGB 0x10BF
+#define CL_sRGBx 0x10C0
+#define CL_sRGBA 0x10C1
+#define CL_sBGRA 0x10C2
+#define CL_ABGR 0x10C3
+
+/* cl_channel_type */
+#define CL_SNORM_INT8 0x10D0
+#define CL_SNORM_INT16 0x10D1
+#define CL_UNORM_INT8 0x10D2
+#define CL_UNORM_INT16 0x10D3
+#define CL_UNORM_SHORT_565 0x10D4
+#define CL_UNORM_SHORT_555 0x10D5
+#define CL_UNORM_INT_101010 0x10D6
+#define CL_SIGNED_INT8 0x10D7
+#define CL_SIGNED_INT16 0x10D8
+#define CL_SIGNED_INT32 0x10D9
+#define CL_UNSIGNED_INT8 0x10DA
+#define CL_UNSIGNED_INT16 0x10DB
+#define CL_UNSIGNED_INT32 0x10DC
+#define CL_HALF_FLOAT 0x10DD
+#define CL_FLOAT 0x10DE
+#define CL_UNORM_INT24 0x10DF
+#define CL_UNORM_INT_101010_2 0x10E0
+
+/* cl_mem_object_type */
+#define CL_MEM_OBJECT_BUFFER 0x10F0
+#define CL_MEM_OBJECT_IMAGE2D 0x10F1
+#define CL_MEM_OBJECT_IMAGE3D 0x10F2
+#define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3
+#define CL_MEM_OBJECT_IMAGE1D 0x10F4
+#define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5
+#define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6
+#define CL_MEM_OBJECT_PIPE 0x10F7
+
+/* cl_mem_info */
+#define CL_MEM_TYPE 0x1100
+#define CL_MEM_FLAGS 0x1101
+#define CL_MEM_SIZE 0x1102
+#define CL_MEM_HOST_PTR 0x1103
+#define CL_MEM_MAP_COUNT 0x1104
+#define CL_MEM_REFERENCE_COUNT 0x1105
+#define CL_MEM_CONTEXT 0x1106
+#define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107
+#define CL_MEM_OFFSET 0x1108
+#define CL_MEM_USES_SVM_POINTER 0x1109
+
+/* cl_image_info */
+#define CL_IMAGE_FORMAT 0x1110
+#define CL_IMAGE_ELEMENT_SIZE 0x1111
+#define CL_IMAGE_ROW_PITCH 0x1112
+#define CL_IMAGE_SLICE_PITCH 0x1113
+#define CL_IMAGE_WIDTH 0x1114
+#define CL_IMAGE_HEIGHT 0x1115
+#define CL_IMAGE_DEPTH 0x1116
+#define CL_IMAGE_ARRAY_SIZE 0x1117
+#define CL_IMAGE_BUFFER 0x1118
+#define CL_IMAGE_NUM_MIP_LEVELS 0x1119
+#define CL_IMAGE_NUM_SAMPLES 0x111A
+
+/* cl_pipe_info */
+#define CL_PIPE_PACKET_SIZE 0x1120
+#define CL_PIPE_MAX_PACKETS 0x1121
+
+/* cl_addressing_mode */
+#define CL_ADDRESS_NONE 0x1130
+#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
+#define CL_ADDRESS_CLAMP 0x1132
+#define CL_ADDRESS_REPEAT 0x1133
+#define CL_ADDRESS_MIRRORED_REPEAT 0x1134
+
+/* cl_filter_mode */
+#define CL_FILTER_NEAREST 0x1140
+#define CL_FILTER_LINEAR 0x1141
+
+/* cl_sampler_info */
+#define CL_SAMPLER_REFERENCE_COUNT 0x1150
+#define CL_SAMPLER_CONTEXT 0x1151
+#define CL_SAMPLER_NORMALIZED_COORDS 0x1152
+#define CL_SAMPLER_ADDRESSING_MODE 0x1153
+#define CL_SAMPLER_FILTER_MODE 0x1154
+#define CL_SAMPLER_MIP_FILTER_MODE 0x1155
+#define CL_SAMPLER_LOD_MIN 0x1156
+#define CL_SAMPLER_LOD_MAX 0x1157
+
+/* cl_map_flags - bitfield */
+#define CL_MAP_READ (1 << 0)
+#define CL_MAP_WRITE (1 << 1)
+#define CL_MAP_WRITE_INVALIDATE_REGION (1 << 2)
+
+/* cl_program_info */
+#define CL_PROGRAM_REFERENCE_COUNT 0x1160
+#define CL_PROGRAM_CONTEXT 0x1161
+#define CL_PROGRAM_NUM_DEVICES 0x1162
+#define CL_PROGRAM_DEVICES 0x1163
+#define CL_PROGRAM_SOURCE 0x1164
+#define CL_PROGRAM_BINARY_SIZES 0x1165
+#define CL_PROGRAM_BINARIES 0x1166
+#define CL_PROGRAM_NUM_KERNELS 0x1167
+#define CL_PROGRAM_KERNEL_NAMES 0x1168
+#define CL_PROGRAM_IL 0x1169
+
+/* cl_program_build_info */
+#define CL_PROGRAM_BUILD_STATUS 0x1181
+#define CL_PROGRAM_BUILD_OPTIONS 0x1182
+#define CL_PROGRAM_BUILD_LOG 0x1183
+#define CL_PROGRAM_BINARY_TYPE 0x1184
+#define CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE 0x1185
+
+/* cl_program_binary_type */
+#define CL_PROGRAM_BINARY_TYPE_NONE 0x0
+#define CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT 0x1
+#define CL_PROGRAM_BINARY_TYPE_LIBRARY 0x2
+#define CL_PROGRAM_BINARY_TYPE_EXECUTABLE 0x4
+
+/* cl_build_status */
+#define CL_BUILD_SUCCESS 0
+#define CL_BUILD_NONE -1
+#define CL_BUILD_ERROR -2
+#define CL_BUILD_IN_PROGRESS -3
+
+/* cl_kernel_info */
+#define CL_KERNEL_FUNCTION_NAME 0x1190
+#define CL_KERNEL_NUM_ARGS 0x1191
+#define CL_KERNEL_REFERENCE_COUNT 0x1192
+#define CL_KERNEL_CONTEXT 0x1193
+#define CL_KERNEL_PROGRAM 0x1194
+#define CL_KERNEL_ATTRIBUTES 0x1195
+#define CL_KERNEL_MAX_NUM_SUB_GROUPS 0x11B9
+#define CL_KERNEL_COMPILE_NUM_SUB_GROUPS 0x11BA
+
+/* cl_kernel_arg_info */
+#define CL_KERNEL_ARG_ADDRESS_QUALIFIER 0x1196
+#define CL_KERNEL_ARG_ACCESS_QUALIFIER 0x1197
+#define CL_KERNEL_ARG_TYPE_NAME 0x1198
+#define CL_KERNEL_ARG_TYPE_QUALIFIER 0x1199
+#define CL_KERNEL_ARG_NAME 0x119A
+
+/* cl_kernel_arg_address_qualifier */
+#define CL_KERNEL_ARG_ADDRESS_GLOBAL 0x119B
+#define CL_KERNEL_ARG_ADDRESS_LOCAL 0x119C
+#define CL_KERNEL_ARG_ADDRESS_CONSTANT 0x119D
+#define CL_KERNEL_ARG_ADDRESS_PRIVATE 0x119E
+
+/* cl_kernel_arg_access_qualifier */
+#define CL_KERNEL_ARG_ACCESS_READ_ONLY 0x11A0
+#define CL_KERNEL_ARG_ACCESS_WRITE_ONLY 0x11A1
+#define CL_KERNEL_ARG_ACCESS_READ_WRITE 0x11A2
+#define CL_KERNEL_ARG_ACCESS_NONE 0x11A3
+
+/* cl_kernel_arg_type_qualifer */
+#define CL_KERNEL_ARG_TYPE_NONE 0
+#define CL_KERNEL_ARG_TYPE_CONST (1 << 0)
+#define CL_KERNEL_ARG_TYPE_RESTRICT (1 << 1)
+#define CL_KERNEL_ARG_TYPE_VOLATILE (1 << 2)
+#define CL_KERNEL_ARG_TYPE_PIPE (1 << 3)
+
+/* cl_kernel_work_group_info */
+#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
+#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
+#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2
+#define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3
+#define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4
+#define CL_KERNEL_GLOBAL_WORK_SIZE 0x11B5
+
+/* cl_kernel_sub_group_info */
+#define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE 0x2033
+#define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE 0x2034
+#define CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT 0x11B8
+
+/* cl_kernel_exec_info */
+#define CL_KERNEL_EXEC_INFO_SVM_PTRS 0x11B6
+#define CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM 0x11B7
+
+/* cl_event_info */
+#define CL_EVENT_COMMAND_QUEUE 0x11D0
+#define CL_EVENT_COMMAND_TYPE 0x11D1
+#define CL_EVENT_REFERENCE_COUNT 0x11D2
+#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
+#define CL_EVENT_CONTEXT 0x11D4
+
+/* cl_command_type */
+#define CL_COMMAND_NDRANGE_KERNEL 0x11F0
+#define CL_COMMAND_TASK 0x11F1
+#define CL_COMMAND_NATIVE_KERNEL 0x11F2
+#define CL_COMMAND_READ_BUFFER 0x11F3
+#define CL_COMMAND_WRITE_BUFFER 0x11F4
+#define CL_COMMAND_COPY_BUFFER 0x11F5
+#define CL_COMMAND_READ_IMAGE 0x11F6
+#define CL_COMMAND_WRITE_IMAGE 0x11F7
+#define CL_COMMAND_COPY_IMAGE 0x11F8
+#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
+#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
+#define CL_COMMAND_MAP_BUFFER 0x11FB
+#define CL_COMMAND_MAP_IMAGE 0x11FC
+#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
+#define CL_COMMAND_MARKER 0x11FE
+#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF
+#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200
+#define CL_COMMAND_READ_BUFFER_RECT 0x1201
+#define CL_COMMAND_WRITE_BUFFER_RECT 0x1202
+#define CL_COMMAND_COPY_BUFFER_RECT 0x1203
+#define CL_COMMAND_USER 0x1204
+#define CL_COMMAND_BARRIER 0x1205
+#define CL_COMMAND_MIGRATE_MEM_OBJECTS 0x1206
+#define CL_COMMAND_FILL_BUFFER 0x1207
+#define CL_COMMAND_FILL_IMAGE 0x1208
+#define CL_COMMAND_SVM_FREE 0x1209
+#define CL_COMMAND_SVM_MEMCPY 0x120A
+#define CL_COMMAND_SVM_MEMFILL 0x120B
+#define CL_COMMAND_SVM_MAP 0x120C
+#define CL_COMMAND_SVM_UNMAP 0x120D
+
+/* command execution status */
+#define CL_COMPLETE 0x0
+#define CL_RUNNING 0x1
+#define CL_SUBMITTED 0x2
+#define CL_QUEUED 0x3
+
+/* cl_buffer_create_type */
+#define CL_BUFFER_CREATE_TYPE_REGION 0x1220
+
+/* cl_profiling_info */
+#define CL_PROFILING_COMMAND_QUEUED 0x1280
+#define CL_PROFILING_COMMAND_SUBMIT 0x1281
+#define CL_PROFILING_COMMAND_START 0x1282
+#define CL_PROFILING_COMMAND_END 0x1283
+#define CL_PROFILING_COMMAND_COMPLETE 0x1284
+
+/********************************************************************************************************/
+
+/* Platform API */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetPlatformIDs(cl_uint /* num_entries */,
+ cl_platform_id * /* platforms */,
+ cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetPlatformInfo(cl_platform_id /* platform */,
+ cl_platform_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Device APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceIDs(cl_platform_id /* platform */,
+ cl_device_type /* device_type */,
+ cl_uint /* num_entries */,
+ cl_device_id * /* devices */,
+ cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceInfo(cl_device_id /* device */,
+ cl_device_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clCreateSubDevices(cl_device_id /* in_device */,
+ const cl_device_partition_property * /* properties */,
+ cl_uint /* num_devices */,
+ cl_device_id * /* out_devices */,
+ cl_uint * /* num_devices_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetDefaultDeviceCommandQueue(cl_context /* context */,
+ cl_device_id /* device */,
+ cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_2_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceAndHostTimer(cl_device_id /* device */,
+ cl_ulong* /* device_timestamp */,
+ cl_ulong* /* host_timestamp */) CL_API_SUFFIX__VERSION_2_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetHostTimer(cl_device_id /* device */,
+ cl_ulong * /* host_timestamp */) CL_API_SUFFIX__VERSION_2_1;
+
+
+/* Context APIs */
+extern CL_API_ENTRY cl_context CL_API_CALL
+clCreateContext(const cl_context_properties * /* properties */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* devices */,
+ void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *),
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_context CL_API_CALL
+clCreateContextFromType(const cl_context_properties * /* properties */,
+ cl_device_type /* device_type */,
+ void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *),
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetContextInfo(cl_context /* context */,
+ cl_context_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Command Queue APIs */
+extern CL_API_ENTRY cl_command_queue CL_API_CALL
+clCreateCommandQueueWithProperties(cl_context /* context */,
+ cl_device_id /* device */,
+ const cl_queue_properties * /* properties */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetCommandQueueInfo(cl_command_queue /* command_queue */,
+ cl_command_queue_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Memory Object APIs */
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateBuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ size_t /* size */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateSubBuffer(cl_mem /* buffer */,
+ cl_mem_flags /* flags */,
+ cl_buffer_create_type /* buffer_create_type */,
+ const void * /* buffer_create_info */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateImage(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ const cl_image_desc * /* image_desc */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreatePipe(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_uint /* pipe_packet_size */,
+ cl_uint /* pipe_max_packets */,
+ const cl_pipe_properties * /* properties */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetSupportedImageFormats(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_mem_object_type /* image_type */,
+ cl_uint /* num_entries */,
+ cl_image_format * /* image_formats */,
+ cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetMemObjectInfo(cl_mem /* memobj */,
+ cl_mem_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetImageInfo(cl_mem /* image */,
+ cl_image_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetPipeInfo(cl_mem /* pipe */,
+ cl_pipe_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_2_0;
+
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetMemObjectDestructorCallback(cl_mem /* memobj */,
+ void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
+ void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1;
+
+/* SVM Allocation APIs */
+extern CL_API_ENTRY void * CL_API_CALL
+clSVMAlloc(cl_context /* context */,
+ cl_svm_mem_flags /* flags */,
+ size_t /* size */,
+ cl_uint /* alignment */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY void CL_API_CALL
+clSVMFree(cl_context /* context */,
+ void * /* svm_pointer */) CL_API_SUFFIX__VERSION_2_0;
+
+/* Sampler APIs */
+extern CL_API_ENTRY cl_sampler CL_API_CALL
+clCreateSamplerWithProperties(cl_context /* context */,
+ const cl_sampler_properties * /* normalized_coords */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetSamplerInfo(cl_sampler /* sampler */,
+ cl_sampler_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Program Object APIs */
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithSource(cl_context /* context */,
+ cl_uint /* count */,
+ const char ** /* strings */,
+ const size_t * /* lengths */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithBinary(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const size_t * /* lengths */,
+ const unsigned char ** /* binaries */,
+ cl_int * /* binary_status */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithBuiltInKernels(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* kernel_names */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithIL(cl_context /* context */,
+ const void* /* il */,
+ size_t /* length */,
+ cl_int* /* errcode_ret */) CL_API_SUFFIX__VERSION_2_1;
+
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clBuildProgram(cl_program /* program */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clCompileProgram(cl_program /* program */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ cl_uint /* num_input_headers */,
+ const cl_program * /* input_headers */,
+ const char ** /* header_include_names */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clLinkProgram(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ cl_uint /* num_input_programs */,
+ const cl_program * /* input_programs */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */,
+ cl_int * /* errcode_ret */ ) CL_API_SUFFIX__VERSION_1_2;
+
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clUnloadPlatformCompiler(cl_platform_id /* platform */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetProgramInfo(cl_program /* program */,
+ cl_program_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetProgramBuildInfo(cl_program /* program */,
+ cl_device_id /* device */,
+ cl_program_build_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Kernel Object APIs */
+extern CL_API_ENTRY cl_kernel CL_API_CALL
+clCreateKernel(cl_program /* program */,
+ const char * /* kernel_name */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clCreateKernelsInProgram(cl_program /* program */,
+ cl_uint /* num_kernels */,
+ cl_kernel * /* kernels */,
+ cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_kernel CL_API_CALL
+clCloneKernel(cl_kernel /* source_kernel */,
+ cl_int* /* errcode_ret */) CL_API_SUFFIX__VERSION_2_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetKernelArg(cl_kernel /* kernel */,
+ cl_uint /* arg_index */,
+ size_t /* arg_size */,
+ const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetKernelArgSVMPointer(cl_kernel /* kernel */,
+ cl_uint /* arg_index */,
+ const void * /* arg_value */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetKernelExecInfo(cl_kernel /* kernel */,
+ cl_kernel_exec_info /* param_name */,
+ size_t /* param_value_size */,
+ const void * /* param_value */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelInfo(cl_kernel /* kernel */,
+ cl_kernel_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelArgInfo(cl_kernel /* kernel */,
+ cl_uint /* arg_indx */,
+ cl_kernel_arg_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelWorkGroupInfo(cl_kernel /* kernel */,
+ cl_device_id /* device */,
+ cl_kernel_work_group_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelSubGroupInfo(cl_kernel /* kernel */,
+ cl_device_id /* device */,
+ cl_kernel_sub_group_info /* param_name */,
+ size_t /* input_value_size */,
+ const void* /*input_value */,
+ size_t /* param_value_size */,
+ void* /* param_value */,
+ size_t* /* param_value_size_ret */ ) CL_API_SUFFIX__VERSION_2_1;
+
+
+/* Event Object APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clWaitForEvents(cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetEventInfo(cl_event /* event */,
+ cl_event_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_event CL_API_CALL
+clCreateUserEvent(cl_context /* context */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetUserEventStatus(cl_event /* event */,
+ cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetEventCallback( cl_event /* event */,
+ cl_int /* command_exec_callback_type */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_1;
+
+/* Profiling APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetEventProfilingInfo(cl_event /* event */,
+ cl_profiling_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Flush and Finish APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Enqueued Commands APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_read */,
+ size_t /* offset */,
+ size_t /* size */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadBufferRect(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_read */,
+ const size_t * /* buffer_offset */,
+ const size_t * /* host_offset */,
+ const size_t * /* region */,
+ size_t /* buffer_row_pitch */,
+ size_t /* buffer_slice_pitch */,
+ size_t /* host_row_pitch */,
+ size_t /* host_slice_pitch */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_write */,
+ size_t /* offset */,
+ size_t /* size */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteBufferRect(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_write */,
+ const size_t * /* buffer_offset */,
+ const size_t * /* host_offset */,
+ const size_t * /* region */,
+ size_t /* buffer_row_pitch */,
+ size_t /* buffer_slice_pitch */,
+ size_t /* host_row_pitch */,
+ size_t /* host_slice_pitch */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueFillBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ const void * /* pattern */,
+ size_t /* pattern_size */,
+ size_t /* offset */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_buffer */,
+ size_t /* src_offset */,
+ size_t /* dst_offset */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBufferRect(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_buffer */,
+ const size_t * /* src_origin */,
+ const size_t * /* dst_origin */,
+ const size_t * /* region */,
+ size_t /* src_row_pitch */,
+ size_t /* src_slice_pitch */,
+ size_t /* dst_row_pitch */,
+ size_t /* dst_slice_pitch */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_read */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* row_pitch */,
+ size_t /* slice_pitch */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_write */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* input_row_pitch */,
+ size_t /* input_slice_pitch */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueFillImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ const void * /* fill_color */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyImage(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_image */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_buffer */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* dst_offset */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_image */,
+ size_t /* src_offset */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY void * CL_API_CALL
+clEnqueueMapBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ size_t /* offset */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY void * CL_API_CALL
+clEnqueueMapImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t * /* image_row_pitch */,
+ size_t * /* image_slice_pitch */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueUnmapMemObject(cl_command_queue /* command_queue */,
+ cl_mem /* memobj */,
+ void * /* mapped_ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueMigrateMemObjects(cl_command_queue /* command_queue */,
+ cl_uint /* num_mem_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_mem_migration_flags /* flags */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueNDRangeKernel(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* work_dim */,
+ const size_t * /* global_work_offset */,
+ const size_t * /* global_work_size */,
+ const size_t * /* local_work_size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueNativeKernel(cl_command_queue /* command_queue */,
+ void (CL_CALLBACK * /*user_func*/)(void *),
+ void * /* args */,
+ size_t /* cb_args */,
+ cl_uint /* num_mem_objects */,
+ const cl_mem * /* mem_list */,
+ const void ** /* args_mem_loc */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueMarkerWithWaitList(cl_command_queue /* command_queue */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueBarrierWithWaitList(cl_command_queue /* command_queue */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueSVMFree(cl_command_queue /* command_queue */,
+ cl_uint /* num_svm_pointers */,
+ void *[] /* svm_pointers[] */,
+ void (CL_CALLBACK * /*pfn_free_func*/)(cl_command_queue /* queue */,
+ cl_uint /* num_svm_pointers */,
+ void *[] /* svm_pointers[] */,
+ void * /* user_data */),
+ void * /* user_data */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueSVMMemcpy(cl_command_queue /* command_queue */,
+ cl_bool /* blocking_copy */,
+ void * /* dst_ptr */,
+ const void * /* src_ptr */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueSVMMemFill(cl_command_queue /* command_queue */,
+ void * /* svm_ptr */,
+ const void * /* pattern */,
+ size_t /* pattern_size */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueSVMMap(cl_command_queue /* command_queue */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* flags */,
+ void * /* svm_ptr */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueSVMUnmap(cl_command_queue /* command_queue */,
+ void * /* svm_ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueSVMMigrateMem(cl_command_queue /* command_queue */,
+ cl_uint /* num_svm_pointers */,
+ const void ** /* svm_pointers */,
+ const size_t * /* sizes */,
+ cl_mem_migration_flags /* flags */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_2_1;
+
+
+/* Extension function access
+ *
+ * Returns the extension function address for the given function name,
+ * or NULL if a valid function can not be found. The client must
+ * check to make sure the address is not NULL, before using or
+ * calling the returned function address.
+ */
+extern CL_API_ENTRY void * CL_API_CALL
+clGetExtensionFunctionAddressForPlatform(cl_platform_id /* platform */,
+ const char * /* func_name */) CL_API_SUFFIX__VERSION_1_2;
+
+
+/* Deprecated OpenCL 1.1 APIs */
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateImage2D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_row_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateImage3D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_depth */,
+ size_t /* image_row_pitch */,
+ size_t /* image_slice_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clEnqueueMarker(cl_command_queue /* command_queue */,
+ cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clEnqueueWaitForEvents(cl_command_queue /* command_queue */,
+ cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clEnqueueBarrier(cl_command_queue /* command_queue */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED void * CL_API_CALL
+clGetExtensionFunctionAddress(const char * /* func_name */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+/* Deprecated OpenCL 2.0 APIs */
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_command_queue CL_API_CALL
+clCreateCommandQueue(cl_context /* context */,
+ cl_device_id /* device */,
+ cl_command_queue_properties /* properties */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED;
+
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_sampler CL_API_CALL
+clCreateSampler(cl_context /* context */,
+ cl_bool /* normalized_coords */,
+ cl_addressing_mode /* addressing_mode */,
+ cl_filter_mode /* filter_mode */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int CL_API_CALL
+clEnqueueTask(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_H */
+
diff --git a/phonelibs/opencl/include/CL/cl_d3d10.h b/phonelibs/opencl/include/CL/cl_d3d10.h
new file mode 100644
index 0000000000..d5960a43f7
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_d3d10.h
@@ -0,0 +1,131 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
+
+#ifndef __OPENCL_CL_D3D10_H
+#define __OPENCL_CL_D3D10_H
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************
+ * cl_khr_d3d10_sharing */
+#define cl_khr_d3d10_sharing 1
+
+typedef cl_uint cl_d3d10_device_source_khr;
+typedef cl_uint cl_d3d10_device_set_khr;
+
+/******************************************************************************/
+
+/* Error Codes */
+#define CL_INVALID_D3D10_DEVICE_KHR -1002
+#define CL_INVALID_D3D10_RESOURCE_KHR -1003
+#define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004
+#define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005
+
+/* cl_d3d10_device_source_nv */
+#define CL_D3D10_DEVICE_KHR 0x4010
+#define CL_D3D10_DXGI_ADAPTER_KHR 0x4011
+
+/* cl_d3d10_device_set_nv */
+#define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012
+#define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013
+
+/* cl_context_info */
+#define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014
+#define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C
+
+/* cl_mem_info */
+#define CL_MEM_D3D10_RESOURCE_KHR 0x4015
+
+/* cl_image_info */
+#define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016
+
+/* cl_command_type */
+#define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017
+#define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018
+
+/******************************************************************************/
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)(
+ cl_platform_id platform,
+ cl_d3d10_device_source_khr d3d_device_source,
+ void * d3d_object,
+ cl_d3d10_device_set_khr d3d_device_set,
+ cl_uint num_entries,
+ cl_device_id * devices,
+ cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)(
+ cl_context context,
+ cl_mem_flags flags,
+ ID3D10Buffer * resource,
+ cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)(
+ cl_context context,
+ cl_mem_flags flags,
+ ID3D10Texture2D * resource,
+ UINT subresource,
+ cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)(
+ cl_context context,
+ cl_mem_flags flags,
+ ID3D10Texture3D * resource,
+ UINT subresource,
+ cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event) CL_API_SUFFIX__VERSION_1_0;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_D3D10_H */
+
diff --git a/phonelibs/opencl/include/CL/cl_d3d11.h b/phonelibs/opencl/include/CL/cl_d3d11.h
new file mode 100644
index 0000000000..39f9072398
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_d3d11.h
@@ -0,0 +1,131 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
+
+#ifndef __OPENCL_CL_D3D11_H
+#define __OPENCL_CL_D3D11_H
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************
+ * cl_khr_d3d11_sharing */
+#define cl_khr_d3d11_sharing 1
+
+typedef cl_uint cl_d3d11_device_source_khr;
+typedef cl_uint cl_d3d11_device_set_khr;
+
+/******************************************************************************/
+
+/* Error Codes */
+#define CL_INVALID_D3D11_DEVICE_KHR -1006
+#define CL_INVALID_D3D11_RESOURCE_KHR -1007
+#define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008
+#define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009
+
+/* cl_d3d11_device_source */
+#define CL_D3D11_DEVICE_KHR 0x4019
+#define CL_D3D11_DXGI_ADAPTER_KHR 0x401A
+
+/* cl_d3d11_device_set */
+#define CL_PREFERRED_DEVICES_FOR_D3D11_KHR 0x401B
+#define CL_ALL_DEVICES_FOR_D3D11_KHR 0x401C
+
+/* cl_context_info */
+#define CL_CONTEXT_D3D11_DEVICE_KHR 0x401D
+#define CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR 0x402D
+
+/* cl_mem_info */
+#define CL_MEM_D3D11_RESOURCE_KHR 0x401E
+
+/* cl_image_info */
+#define CL_IMAGE_D3D11_SUBRESOURCE_KHR 0x401F
+
+/* cl_command_type */
+#define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR 0x4020
+#define CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR 0x4021
+
+/******************************************************************************/
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11KHR_fn)(
+ cl_platform_id platform,
+ cl_d3d11_device_source_khr d3d_device_source,
+ void * d3d_object,
+ cl_d3d11_device_set_khr d3d_device_set,
+ cl_uint num_entries,
+ cl_device_id * devices,
+ cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11BufferKHR_fn)(
+ cl_context context,
+ cl_mem_flags flags,
+ ID3D11Buffer * resource,
+ cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DKHR_fn)(
+ cl_context context,
+ cl_mem_flags flags,
+ ID3D11Texture2D * resource,
+ UINT subresource,
+ cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DKHR_fn)(
+ cl_context context,
+ cl_mem_flags flags,
+ ID3D11Texture3D * resource,
+ UINT subresource,
+ cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event) CL_API_SUFFIX__VERSION_1_2;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_D3D11_H */
+
diff --git a/phonelibs/opencl/include/CL/cl_dx9_media_sharing.h b/phonelibs/opencl/include/CL/cl_dx9_media_sharing.h
new file mode 100644
index 0000000000..2729e8b9e8
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_dx9_media_sharing.h
@@ -0,0 +1,132 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
+
+#ifndef __OPENCL_CL_DX9_MEDIA_SHARING_H
+#define __OPENCL_CL_DX9_MEDIA_SHARING_H
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************/
+/* cl_khr_dx9_media_sharing */
+#define cl_khr_dx9_media_sharing 1
+
+typedef cl_uint cl_dx9_media_adapter_type_khr;
+typedef cl_uint cl_dx9_media_adapter_set_khr;
+
+#if defined(_WIN32)
+#include
+typedef struct _cl_dx9_surface_info_khr
+{
+ IDirect3DSurface9 *resource;
+ HANDLE shared_handle;
+} cl_dx9_surface_info_khr;
+#endif
+
+
+/******************************************************************************/
+
+/* Error Codes */
+#define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010
+#define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011
+#define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012
+#define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013
+
+/* cl_media_adapter_type_khr */
+#define CL_ADAPTER_D3D9_KHR 0x2020
+#define CL_ADAPTER_D3D9EX_KHR 0x2021
+#define CL_ADAPTER_DXVA_KHR 0x2022
+
+/* cl_media_adapter_set_khr */
+#define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023
+#define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024
+
+/* cl_context_info */
+#define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025
+#define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026
+#define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027
+
+/* cl_mem_info */
+#define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028
+#define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029
+
+/* cl_image_info */
+#define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A
+
+/* cl_command_type */
+#define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B
+#define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C
+
+/******************************************************************************/
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)(
+ cl_platform_id platform,
+ cl_uint num_media_adapters,
+ cl_dx9_media_adapter_type_khr * media_adapter_type,
+ void * media_adapters,
+ cl_dx9_media_adapter_set_khr media_adapter_set,
+ cl_uint num_entries,
+ cl_device_id * devices,
+ cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)(
+ cl_context context,
+ cl_mem_flags flags,
+ cl_dx9_media_adapter_type_khr adapter_type,
+ void * surface_info,
+ cl_uint plane,
+ cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event) CL_API_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event) CL_API_SUFFIX__VERSION_1_2;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */
+
diff --git a/phonelibs/opencl/include/CL/cl_egl.h b/phonelibs/opencl/include/CL/cl_egl.h
new file mode 100644
index 0000000000..a765bd5266
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_egl.h
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+#ifndef __OPENCL_CL_EGL_H
+#define __OPENCL_CL_EGL_H
+
+#ifdef __APPLE__
+
+#else
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Command type for events created with clEnqueueAcquireEGLObjectsKHR */
+#define CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR 0x202F
+#define CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR 0x202D
+#define CL_COMMAND_RELEASE_EGL_OBJECTS_KHR 0x202E
+
+/* Error type for clCreateFromEGLImageKHR */
+#define CL_INVALID_EGL_OBJECT_KHR -1093
+#define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092
+
+/* CLeglImageKHR is an opaque handle to an EGLImage */
+typedef void* CLeglImageKHR;
+
+/* CLeglDisplayKHR is an opaque handle to an EGLDisplay */
+typedef void* CLeglDisplayKHR;
+
+/* CLeglSyncKHR is an opaque handle to an EGLSync object */
+typedef void* CLeglSyncKHR;
+
+/* properties passed to clCreateFromEGLImageKHR */
+typedef intptr_t cl_egl_image_properties_khr;
+
+
+#define cl_khr_egl_image 1
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromEGLImageKHR(cl_context /* context */,
+ CLeglDisplayKHR /* egldisplay */,
+ CLeglImageKHR /* eglimage */,
+ cl_mem_flags /* flags */,
+ const cl_egl_image_properties_khr * /* properties */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromEGLImageKHR_fn)(
+ cl_context context,
+ CLeglDisplayKHR egldisplay,
+ CLeglImageKHR eglimage,
+ cl_mem_flags flags,
+ const cl_egl_image_properties_khr * properties,
+ cl_int * errcode_ret);
+
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueAcquireEGLObjectsKHR(cl_command_queue /* command_queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event);
+
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReleaseEGLObjectsKHR(cl_command_queue /* command_queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)(
+ cl_command_queue command_queue,
+ cl_uint num_objects,
+ const cl_mem * mem_objects,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event);
+
+
+#define cl_khr_egl_event 1
+
+extern CL_API_ENTRY cl_event CL_API_CALL
+clCreateEventFromEGLSyncKHR(cl_context /* context */,
+ CLeglSyncKHR /* sync */,
+ CLeglDisplayKHR /* display */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_event (CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)(
+ cl_context context,
+ CLeglSyncKHR sync,
+ CLeglDisplayKHR display,
+ cl_int * errcode_ret);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_EGL_H */
diff --git a/phonelibs/opencl/include/CL/cl_ext.h b/phonelibs/opencl/include/CL/cl_ext.h
new file mode 100644
index 0000000000..7941583895
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_ext.h
@@ -0,0 +1,391 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+/* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */
+
+/* cl_ext.h contains OpenCL extensions which don't have external */
+/* (OpenGL, D3D) dependencies. */
+
+#ifndef __CL_EXT_H
+#define __CL_EXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __APPLE__
+ #include
+ #include
+#else
+ #include
+#endif
+
+/* cl_khr_fp16 extension - no extension #define since it has no functions */
+#define CL_DEVICE_HALF_FP_CONFIG 0x1033
+
+/* Memory object destruction
+ *
+ * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
+ *
+ * Registers a user callback function that will be called when the memory object is deleted and its resources
+ * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
+ * stack associated with memobj. The registered user callback functions are called in the reverse order in
+ * which they were registered. The user callback functions are called and then the memory object is deleted
+ * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
+ * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
+ * the storage bits for the memory object, can be reused or freed.
+ *
+ * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
+ *
+ * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
+ * before using.
+ */
+#define cl_APPLE_SetMemObjectDestructor 1
+cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
+ void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
+ void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+
+/* Context Logging Functions
+ *
+ * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
+ * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
+ * before using.
+ *
+ * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
+ */
+#define cl_APPLE_ContextLoggingFunctions 1
+extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */,
+ const void * /* private_info */,
+ size_t /* cb */,
+ void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
+extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */,
+ const void * /* private_info */,
+ size_t /* cb */,
+ void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
+extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */,
+ const void * /* private_info */,
+ size_t /* cb */,
+ void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+
+/************************
+* cl_khr_icd extension *
+************************/
+#define cl_khr_icd 1
+
+/* cl_platform_info */
+#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920
+
+/* Additional Error Codes */
+#define CL_PLATFORM_NOT_FOUND_KHR -1001
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clIcdGetPlatformIDsKHR(cl_uint /* num_entries */,
+ cl_platform_id * /* platforms */,
+ cl_uint * /* num_platforms */);
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(
+ cl_uint /* num_entries */,
+ cl_platform_id * /* platforms */,
+ cl_uint * /* num_platforms */);
+
+
+/* Extension: cl_khr_image2D_buffer
+ *
+ * This extension allows a 2D image to be created from a cl_mem buffer without a copy.
+ * The type associated with a 2D image created from a buffer in an OpenCL program is image2d_t.
+ * Both the sampler and sampler-less read_image built-in functions are supported for 2D images
+ * and 2D images created from a buffer. Similarly, the write_image built-ins are also supported
+ * for 2D images created from a buffer.
+ *
+ * When the 2D image from buffer is created, the client must specify the width,
+ * height, image format (i.e. channel order and channel data type) and optionally the row pitch
+ *
+ * The pitch specified must be a multiple of CL_DEVICE_IMAGE_PITCH_ALIGNMENT pixels.
+ * The base address of the buffer must be aligned to CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT pixels.
+ */
+
+/*************************************
+ * cl_khr_initalize_memory extension *
+ *************************************/
+
+#define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x2030
+
+
+/**************************************
+ * cl_khr_terminate_context extension *
+ **************************************/
+
+#define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x2031
+#define CL_CONTEXT_TERMINATE_KHR 0x2032
+
+#define cl_khr_terminate_context 1
+extern CL_API_ENTRY cl_int CL_API_CALL clTerminateContextKHR(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
+
+
+/*
+ * Extension: cl_khr_spir
+ *
+ * This extension adds support to create an OpenCL program object from a
+ * Standard Portable Intermediate Representation (SPIR) instance
+ */
+
+#define CL_DEVICE_SPIR_VERSIONS 0x40E0
+#define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1
+
+
+/******************************************
+* cl_nv_device_attribute_query extension *
+******************************************/
+/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
+#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
+#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
+#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
+#define CL_DEVICE_WARP_SIZE_NV 0x4003
+#define CL_DEVICE_GPU_OVERLAP_NV 0x4004
+#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
+#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
+
+/*********************************
+* cl_amd_device_attribute_query *
+*********************************/
+#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
+
+/*********************************
+* cl_arm_printf extension
+*********************************/
+#define CL_PRINTF_CALLBACK_ARM 0x40B0
+#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1
+
+#ifdef CL_VERSION_1_1
+ /***********************************
+ * cl_ext_device_fission extension *
+ ***********************************/
+ #define cl_ext_device_fission 1
+
+ extern CL_API_ENTRY cl_int CL_API_CALL
+ clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef CL_API_ENTRY cl_int
+ (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ extern CL_API_ENTRY cl_int CL_API_CALL
+ clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef CL_API_ENTRY cl_int
+ (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef cl_ulong cl_device_partition_property_ext;
+ extern CL_API_ENTRY cl_int CL_API_CALL
+ clCreateSubDevicesEXT( cl_device_id /*in_device*/,
+ const cl_device_partition_property_ext * /* properties */,
+ cl_uint /*num_entries*/,
+ cl_device_id * /*out_devices*/,
+ cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef CL_API_ENTRY cl_int
+ ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
+ const cl_device_partition_property_ext * /* properties */,
+ cl_uint /*num_entries*/,
+ cl_device_id * /*out_devices*/,
+ cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ /* cl_device_partition_property_ext */
+ #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
+ #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
+ #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
+ #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
+
+ /* clDeviceGetInfo selectors */
+ #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
+ #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
+ #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
+ #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
+ #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
+
+ /* error codes */
+ #define CL_DEVICE_PARTITION_FAILED_EXT -1057
+ #define CL_INVALID_PARTITION_COUNT_EXT -1058
+ #define CL_INVALID_PARTITION_NAME_EXT -1059
+
+ /* CL_AFFINITY_DOMAINs */
+ #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
+ #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
+ #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
+ #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
+ #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
+ #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
+
+ /* cl_device_partition_property_ext list terminators */
+ #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
+ #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
+ #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
+
+/*********************************
+* cl_qcom_ext_host_ptr extension
+*********************************/
+
+#define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29)
+
+#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0
+#define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1
+#define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2
+#define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3
+#define CL_MEM_HOST_UNCACHED_QCOM 0x40A4
+#define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5
+#define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6
+#define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7
+
+typedef cl_uint cl_image_pitch_info_qcom;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceImageInfoQCOM(cl_device_id device,
+ size_t image_width,
+ size_t image_height,
+ const cl_image_format *image_format,
+ cl_image_pitch_info_qcom param_name,
+ size_t param_value_size,
+ void *param_value,
+ size_t *param_value_size_ret);
+
+typedef struct _cl_mem_ext_host_ptr
+{
+ /* Type of external memory allocation. */
+ /* Legal values will be defined in layered extensions. */
+ cl_uint allocation_type;
+
+ /* Host cache policy for this external memory allocation. */
+ cl_uint host_cache_policy;
+
+} cl_mem_ext_host_ptr;
+
+/*********************************
+* cl_qcom_ion_host_ptr extension
+*********************************/
+
+#define CL_MEM_ION_HOST_PTR_QCOM 0x40A8
+
+typedef struct _cl_mem_ion_host_ptr
+{
+ /* Type of external memory allocation. */
+ /* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */
+ cl_mem_ext_host_ptr ext_host_ptr;
+
+ /* ION file descriptor */
+ int ion_filedesc;
+
+ /* Host pointer to the ION allocated memory */
+ void* ion_hostptr;
+
+} cl_mem_ion_host_ptr;
+
+#endif /* CL_VERSION_1_1 */
+
+
+#ifdef CL_VERSION_2_0
+/*********************************
+* cl_khr_sub_groups extension
+*********************************/
+#define cl_khr_sub_groups 1
+
+typedef cl_uint cl_kernel_sub_group_info_khr;
+
+/* cl_khr_sub_group_info */
+#define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR 0x2033
+#define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR 0x2034
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelSubGroupInfoKHR(cl_kernel /* in_kernel */,
+ cl_device_id /*in_device*/,
+ cl_kernel_sub_group_info_khr /* param_name */,
+ size_t /*input_value_size*/,
+ const void * /*input_value*/,
+ size_t /*param_value_size*/,
+ void* /*param_value*/,
+ size_t* /*param_value_size_ret*/ ) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
+
+typedef CL_API_ENTRY cl_int
+ ( CL_API_CALL * clGetKernelSubGroupInfoKHR_fn)(cl_kernel /* in_kernel */,
+ cl_device_id /*in_device*/,
+ cl_kernel_sub_group_info_khr /* param_name */,
+ size_t /*input_value_size*/,
+ const void * /*input_value*/,
+ size_t /*param_value_size*/,
+ void* /*param_value*/,
+ size_t* /*param_value_size_ret*/ ) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
+#endif /* CL_VERSION_2_0 */
+
+#ifdef CL_VERSION_2_1
+/*********************************
+* cl_khr_priority_hints extension
+*********************************/
+#define cl_khr_priority_hints 1
+
+typedef cl_uint cl_queue_priority_khr;
+
+/* cl_command_queue_properties */
+#define CL_QUEUE_PRIORITY_KHR 0x1096
+
+/* cl_queue_priority_khr */
+#define CL_QUEUE_PRIORITY_HIGH_KHR (1<<0)
+#define CL_QUEUE_PRIORITY_MED_KHR (1<<1)
+#define CL_QUEUE_PRIORITY_LOW_KHR (1<<2)
+
+#endif /* CL_VERSION_2_1 */
+
+#ifdef CL_VERSION_2_1
+/*********************************
+* cl_khr_throttle_hints extension
+*********************************/
+#define cl_khr_throttle_hints 1
+
+typedef cl_uint cl_queue_throttle_khr;
+
+/* cl_command_queue_properties */
+#define CL_QUEUE_THROTTLE_KHR 0x1097
+
+/* cl_queue_throttle_khr */
+#define CL_QUEUE_THROTTLE_HIGH_KHR (1<<0)
+#define CL_QUEUE_THROTTLE_MED_KHR (1<<1)
+#define CL_QUEUE_THROTTLE_LOW_KHR (1<<2)
+
+#endif /* CL_VERSION_2_1 */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __CL_EXT_H */
diff --git a/phonelibs/opencl/include/CL/cl_gl.h b/phonelibs/opencl/include/CL/cl_gl.h
new file mode 100644
index 0000000000..945daa83d7
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_gl.h
@@ -0,0 +1,167 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+#ifndef __OPENCL_CL_GL_H
+#define __OPENCL_CL_GL_H
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef cl_uint cl_gl_object_type;
+typedef cl_uint cl_gl_texture_info;
+typedef cl_uint cl_gl_platform_info;
+typedef struct __GLsync *cl_GLsync;
+
+/* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */
+#define CL_GL_OBJECT_BUFFER 0x2000
+#define CL_GL_OBJECT_TEXTURE2D 0x2001
+#define CL_GL_OBJECT_TEXTURE3D 0x2002
+#define CL_GL_OBJECT_RENDERBUFFER 0x2003
+#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E
+#define CL_GL_OBJECT_TEXTURE1D 0x200F
+#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010
+#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011
+
+/* cl_gl_texture_info */
+#define CL_GL_TEXTURE_TARGET 0x2004
+#define CL_GL_MIPMAP_LEVEL 0x2005
+#define CL_GL_NUM_SAMPLES 0x2012
+
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLBuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLuint /* bufobj */,
+ int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLTexture(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLenum /* target */,
+ cl_GLint /* miplevel */,
+ cl_GLuint /* texture */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLRenderbuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLuint /* renderbuffer */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLObjectInfo(cl_mem /* memobj */,
+ cl_gl_object_type * /* gl_object_type */,
+ cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLTextureInfo(cl_mem /* memobj */,
+ cl_gl_texture_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+
+/* Deprecated OpenCL 1.1 APIs */
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateFromGLTexture2D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLenum /* target */,
+ cl_GLint /* miplevel */,
+ cl_GLuint /* texture */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateFromGLTexture3D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLenum /* target */,
+ cl_GLint /* miplevel */,
+ cl_GLuint /* texture */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+/* cl_khr_gl_sharing extension */
+
+#define cl_khr_gl_sharing 1
+
+typedef cl_uint cl_gl_context_info;
+
+/* Additional Error Codes */
+#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000
+
+/* cl_gl_context_info */
+#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006
+#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007
+
+/* Additional cl_context_properties */
+#define CL_GL_CONTEXT_KHR 0x2008
+#define CL_EGL_DISPLAY_KHR 0x2009
+#define CL_GLX_DISPLAY_KHR 0x200A
+#define CL_WGL_HDC_KHR 0x200B
+#define CL_CGL_SHAREGROUP_KHR 0x200C
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLContextInfoKHR(const cl_context_properties * /* properties */,
+ cl_gl_context_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
+ const cl_context_properties * properties,
+ cl_gl_context_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_GL_H */
diff --git a/phonelibs/opencl/include/CL/cl_gl_ext.h b/phonelibs/opencl/include/CL/cl_gl_ext.h
new file mode 100644
index 0000000000..e3c14c6408
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_gl_ext.h
@@ -0,0 +1,74 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
+
+/* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */
+/* OpenGL dependencies. */
+
+#ifndef __OPENCL_CL_GL_EXT_H
+#define __OPENCL_CL_GL_EXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+/*
+ * For each extension, follow this template
+ * cl_VEN_extname extension */
+/* #define cl_VEN_extname 1
+ * ... define new types, if any
+ * ... define new tokens, if any
+ * ... define new APIs, if any
+ *
+ * If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header
+ * This allows us to avoid having to decide whether to include GL headers or GLES here.
+ */
+
+/*
+ * cl_khr_gl_event extension
+ * See section 9.9 in the OpenCL 1.1 spec for more information
+ */
+#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D
+
+extern CL_API_ENTRY cl_event CL_API_CALL
+clCreateEventFromGLsyncKHR(cl_context /* context */,
+ cl_GLsync /* cl_GLsync */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_GL_EXT_H */
diff --git a/phonelibs/opencl/include/CL/cl_platform.h b/phonelibs/opencl/include/CL/cl_platform.h
new file mode 100644
index 0000000000..4e334a2918
--- /dev/null
+++ b/phonelibs/opencl/include/CL/cl_platform.h
@@ -0,0 +1,1333 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+/* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */
+
+#ifndef __CL_PLATFORM_H
+#define __CL_PLATFORM_H
+
+#ifdef __APPLE__
+ /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
+ #include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32)
+ #define CL_API_ENTRY
+ #define CL_API_CALL __stdcall
+ #define CL_CALLBACK __stdcall
+#else
+ #define CL_API_ENTRY
+ #define CL_API_CALL
+ #define CL_CALLBACK
+#endif
+
+/*
+ * Deprecation flags refer to the last version of the header in which the
+ * feature was not deprecated.
+ *
+ * E.g. VERSION_1_1_DEPRECATED means the feature is present in 1.1 without
+ * deprecation but is deprecated in versions later than 1.1.
+ */
+
+#ifdef __APPLE__
+ #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
+ #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+ #define CL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define GCL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
+
+ #ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
+ #else
+ #warning This path should never happen outside of internal operating system development. AvailabilityMacros do not function correctly here!
+ #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #endif
+#else
+ #define CL_EXTENSION_WEAK_LINK
+ #define CL_API_SUFFIX__VERSION_1_0
+ #define CL_EXT_SUFFIX__VERSION_1_0
+ #define CL_API_SUFFIX__VERSION_1_1
+ #define CL_EXT_SUFFIX__VERSION_1_1
+ #define CL_API_SUFFIX__VERSION_1_2
+ #define CL_EXT_SUFFIX__VERSION_1_2
+ #define CL_API_SUFFIX__VERSION_2_0
+ #define CL_EXT_SUFFIX__VERSION_2_0
+ #define CL_API_SUFFIX__VERSION_2_1
+ #define CL_EXT_SUFFIX__VERSION_2_1
+
+ #ifdef __GNUC__
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED __attribute__((deprecated))
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED __attribute__((deprecated))
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED __attribute__((deprecated))
+ #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
+ #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED __attribute__((deprecated))
+ #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
+ #endif
+ #elif _WIN32
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED __declspec(deprecated)
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED __declspec(deprecated)
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED __declspec(deprecated)
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
+ #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED __declspec(deprecated)
+ #endif
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+
+ #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
+
+ #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
+ #endif
+#endif
+
+#if (defined (_WIN32) && defined(_MSC_VER))
+
+/* scalar types */
+typedef signed __int8 cl_char;
+typedef unsigned __int8 cl_uchar;
+typedef signed __int16 cl_short;
+typedef unsigned __int16 cl_ushort;
+typedef signed __int32 cl_int;
+typedef unsigned __int32 cl_uint;
+typedef signed __int64 cl_long;
+typedef unsigned __int64 cl_ulong;
+
+typedef unsigned __int16 cl_half;
+typedef float cl_float;
+typedef double cl_double;
+
+/* Macro names and corresponding values defined by OpenCL */
+#define CL_CHAR_BIT 8
+#define CL_SCHAR_MAX 127
+#define CL_SCHAR_MIN (-127-1)
+#define CL_CHAR_MAX CL_SCHAR_MAX
+#define CL_CHAR_MIN CL_SCHAR_MIN
+#define CL_UCHAR_MAX 255
+#define CL_SHRT_MAX 32767
+#define CL_SHRT_MIN (-32767-1)
+#define CL_USHRT_MAX 65535
+#define CL_INT_MAX 2147483647
+#define CL_INT_MIN (-2147483647-1)
+#define CL_UINT_MAX 0xffffffffU
+#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
+#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
+#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
+
+#define CL_FLT_DIG 6
+#define CL_FLT_MANT_DIG 24
+#define CL_FLT_MAX_10_EXP +38
+#define CL_FLT_MAX_EXP +128
+#define CL_FLT_MIN_10_EXP -37
+#define CL_FLT_MIN_EXP -125
+#define CL_FLT_RADIX 2
+#define CL_FLT_MAX 340282346638528859811704183484516925440.0f
+#define CL_FLT_MIN 1.175494350822287507969e-38f
+#define CL_FLT_EPSILON 0x1.0p-23f
+
+#define CL_DBL_DIG 15
+#define CL_DBL_MANT_DIG 53
+#define CL_DBL_MAX_10_EXP +308
+#define CL_DBL_MAX_EXP +1024
+#define CL_DBL_MIN_10_EXP -307
+#define CL_DBL_MIN_EXP -1021
+#define CL_DBL_RADIX 2
+#define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
+#define CL_DBL_MIN 2.225073858507201383090e-308
+#define CL_DBL_EPSILON 2.220446049250313080847e-16
+
+#define CL_M_E 2.718281828459045090796
+#define CL_M_LOG2E 1.442695040888963387005
+#define CL_M_LOG10E 0.434294481903251816668
+#define CL_M_LN2 0.693147180559945286227
+#define CL_M_LN10 2.302585092994045901094
+#define CL_M_PI 3.141592653589793115998
+#define CL_M_PI_2 1.570796326794896557999
+#define CL_M_PI_4 0.785398163397448278999
+#define CL_M_1_PI 0.318309886183790691216
+#define CL_M_2_PI 0.636619772367581382433
+#define CL_M_2_SQRTPI 1.128379167095512558561
+#define CL_M_SQRT2 1.414213562373095145475
+#define CL_M_SQRT1_2 0.707106781186547572737
+
+#define CL_M_E_F 2.71828174591064f
+#define CL_M_LOG2E_F 1.44269502162933f
+#define CL_M_LOG10E_F 0.43429449200630f
+#define CL_M_LN2_F 0.69314718246460f
+#define CL_M_LN10_F 2.30258512496948f
+#define CL_M_PI_F 3.14159274101257f
+#define CL_M_PI_2_F 1.57079637050629f
+#define CL_M_PI_4_F 0.78539818525314f
+#define CL_M_1_PI_F 0.31830987334251f
+#define CL_M_2_PI_F 0.63661974668503f
+#define CL_M_2_SQRTPI_F 1.12837922573090f
+#define CL_M_SQRT2_F 1.41421353816986f
+#define CL_M_SQRT1_2_F 0.70710676908493f
+
+#define CL_NAN (CL_INFINITY - CL_INFINITY)
+#define CL_HUGE_VALF ((cl_float) 1e50)
+#define CL_HUGE_VAL ((cl_double) 1e500)
+#define CL_MAXFLOAT CL_FLT_MAX
+#define CL_INFINITY CL_HUGE_VALF
+
+#else
+
+#include
+
+/* scalar types */
+typedef int8_t cl_char;
+typedef uint8_t cl_uchar;
+typedef int16_t cl_short __attribute__((aligned(2)));
+typedef uint16_t cl_ushort __attribute__((aligned(2)));
+typedef int32_t cl_int __attribute__((aligned(4)));
+typedef uint32_t cl_uint __attribute__((aligned(4)));
+typedef int64_t cl_long __attribute__((aligned(8)));
+typedef uint64_t cl_ulong __attribute__((aligned(8)));
+
+typedef uint16_t cl_half __attribute__((aligned(2)));
+typedef float cl_float __attribute__((aligned(4)));
+typedef double cl_double __attribute__((aligned(8)));
+
+/* Macro names and corresponding values defined by OpenCL */
+#define CL_CHAR_BIT 8
+#define CL_SCHAR_MAX 127
+#define CL_SCHAR_MIN (-127-1)
+#define CL_CHAR_MAX CL_SCHAR_MAX
+#define CL_CHAR_MIN CL_SCHAR_MIN
+#define CL_UCHAR_MAX 255
+#define CL_SHRT_MAX 32767
+#define CL_SHRT_MIN (-32767-1)
+#define CL_USHRT_MAX 65535
+#define CL_INT_MAX 2147483647
+#define CL_INT_MIN (-2147483647-1)
+#define CL_UINT_MAX 0xffffffffU
+#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
+#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
+#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
+
+#define CL_FLT_DIG 6
+#define CL_FLT_MANT_DIG 24
+#define CL_FLT_MAX_10_EXP +38
+#define CL_FLT_MAX_EXP +128
+#define CL_FLT_MIN_10_EXP -37
+#define CL_FLT_MIN_EXP -125
+#define CL_FLT_RADIX 2
+#define CL_FLT_MAX 0x1.fffffep127f
+#define CL_FLT_MIN 0x1.0p-126f
+#define CL_FLT_EPSILON 0x1.0p-23f
+
+#define CL_DBL_DIG 15
+#define CL_DBL_MANT_DIG 53
+#define CL_DBL_MAX_10_EXP +308
+#define CL_DBL_MAX_EXP +1024
+#define CL_DBL_MIN_10_EXP -307
+#define CL_DBL_MIN_EXP -1021
+#define CL_DBL_RADIX 2
+#define CL_DBL_MAX 0x1.fffffffffffffp1023
+#define CL_DBL_MIN 0x1.0p-1022
+#define CL_DBL_EPSILON 0x1.0p-52
+
+#define CL_M_E 2.718281828459045090796
+#define CL_M_LOG2E 1.442695040888963387005
+#define CL_M_LOG10E 0.434294481903251816668
+#define CL_M_LN2 0.693147180559945286227
+#define CL_M_LN10 2.302585092994045901094
+#define CL_M_PI 3.141592653589793115998
+#define CL_M_PI_2 1.570796326794896557999
+#define CL_M_PI_4 0.785398163397448278999
+#define CL_M_1_PI 0.318309886183790691216
+#define CL_M_2_PI 0.636619772367581382433
+#define CL_M_2_SQRTPI 1.128379167095512558561
+#define CL_M_SQRT2 1.414213562373095145475
+#define CL_M_SQRT1_2 0.707106781186547572737
+
+#define CL_M_E_F 2.71828174591064f
+#define CL_M_LOG2E_F 1.44269502162933f
+#define CL_M_LOG10E_F 0.43429449200630f
+#define CL_M_LN2_F 0.69314718246460f
+#define CL_M_LN10_F 2.30258512496948f
+#define CL_M_PI_F 3.14159274101257f
+#define CL_M_PI_2_F 1.57079637050629f
+#define CL_M_PI_4_F 0.78539818525314f
+#define CL_M_1_PI_F 0.31830987334251f
+#define CL_M_2_PI_F 0.63661974668503f
+#define CL_M_2_SQRTPI_F 1.12837922573090f
+#define CL_M_SQRT2_F 1.41421353816986f
+#define CL_M_SQRT1_2_F 0.70710676908493f
+
+#if defined( __GNUC__ )
+ #define CL_HUGE_VALF __builtin_huge_valf()
+ #define CL_HUGE_VAL __builtin_huge_val()
+ #define CL_NAN __builtin_nanf( "" )
+#else
+ #define CL_HUGE_VALF ((cl_float) 1e50)
+ #define CL_HUGE_VAL ((cl_double) 1e500)
+ float nanf( const char * );
+ #define CL_NAN nanf( "" )
+#endif
+#define CL_MAXFLOAT CL_FLT_MAX
+#define CL_INFINITY CL_HUGE_VALF
+
+#endif
+
+#include
+
+/* Mirror types to GL types. Mirror types allow us to avoid deciding which 87s to load based on whether we are using GL or GLES here. */
+typedef unsigned int cl_GLuint;
+typedef int cl_GLint;
+typedef unsigned int cl_GLenum;
+
+/*
+ * Vector types
+ *
+ * Note: OpenCL requires that all types be naturally aligned.
+ * This means that vector types must be naturally aligned.
+ * For example, a vector of four floats must be aligned to
+ * a 16 byte boundary (calculated as 4 * the natural 4-byte
+ * alignment of the float). The alignment qualifiers here
+ * will only function properly if your compiler supports them
+ * and if you don't actively work to defeat them. For example,
+ * in order for a cl_float4 to be 16 byte aligned in a struct,
+ * the start of the struct must itself be 16-byte aligned.
+ *
+ * Maintaining proper alignment is the user's responsibility.
+ */
+
+/* Define basic vector types */
+#if defined( __VEC__ )
+ #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
+ typedef vector unsigned char __cl_uchar16;
+ typedef vector signed char __cl_char16;
+ typedef vector unsigned short __cl_ushort8;
+ typedef vector signed short __cl_short8;
+ typedef vector unsigned int __cl_uint4;
+ typedef vector signed int __cl_int4;
+ typedef vector float __cl_float4;
+ #define __CL_UCHAR16__ 1
+ #define __CL_CHAR16__ 1
+ #define __CL_USHORT8__ 1
+ #define __CL_SHORT8__ 1
+ #define __CL_UINT4__ 1
+ #define __CL_INT4__ 1
+ #define __CL_FLOAT4__ 1
+#endif
+
+#if defined( __SSE__ )
+ #if defined( __MINGW64__ )
+ #include
+ #else
+ #include
+ #endif
+ #if defined( __GNUC__ )
+ typedef float __cl_float4 __attribute__((vector_size(16)));
+ #else
+ typedef __m128 __cl_float4;
+ #endif
+ #define __CL_FLOAT4__ 1
+#endif
+
+#if defined( __SSE2__ )
+ #if defined( __MINGW64__ )
+ #include
+ #else
+ #include
+ #endif
+ #if defined( __GNUC__ )
+ typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16)));
+ typedef cl_char __cl_char16 __attribute__((vector_size(16)));
+ typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16)));
+ typedef cl_short __cl_short8 __attribute__((vector_size(16)));
+ typedef cl_uint __cl_uint4 __attribute__((vector_size(16)));
+ typedef cl_int __cl_int4 __attribute__((vector_size(16)));
+ typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16)));
+ typedef cl_long __cl_long2 __attribute__((vector_size(16)));
+ typedef cl_double __cl_double2 __attribute__((vector_size(16)));
+ #else
+ typedef __m128i __cl_uchar16;
+ typedef __m128i __cl_char16;
+ typedef __m128i __cl_ushort8;
+ typedef __m128i __cl_short8;
+ typedef __m128i __cl_uint4;
+ typedef __m128i __cl_int4;
+ typedef __m128i __cl_ulong2;
+ typedef __m128i __cl_long2;
+ typedef __m128d __cl_double2;
+ #endif
+ #define __CL_UCHAR16__ 1
+ #define __CL_CHAR16__ 1
+ #define __CL_USHORT8__ 1
+ #define __CL_SHORT8__ 1
+ #define __CL_INT4__ 1
+ #define __CL_UINT4__ 1
+ #define __CL_ULONG2__ 1
+ #define __CL_LONG2__ 1
+ #define __CL_DOUBLE2__ 1
+#endif
+
+#if defined( __MMX__ )
+ #include
+ #if defined( __GNUC__ )
+ typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8)));
+ typedef cl_char __cl_char8 __attribute__((vector_size(8)));
+ typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8)));
+ typedef cl_short __cl_short4 __attribute__((vector_size(8)));
+ typedef cl_uint __cl_uint2 __attribute__((vector_size(8)));
+ typedef cl_int __cl_int2 __attribute__((vector_size(8)));
+ typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8)));
+ typedef cl_long __cl_long1 __attribute__((vector_size(8)));
+ typedef cl_float __cl_float2 __attribute__((vector_size(8)));
+ #else
+ typedef __m64 __cl_uchar8;
+ typedef __m64 __cl_char8;
+ typedef __m64 __cl_ushort4;
+ typedef __m64 __cl_short4;
+ typedef __m64 __cl_uint2;
+ typedef __m64 __cl_int2;
+ typedef __m64 __cl_ulong1;
+ typedef __m64 __cl_long1;
+ typedef __m64 __cl_float2;
+ #endif
+ #define __CL_UCHAR8__ 1
+ #define __CL_CHAR8__ 1
+ #define __CL_USHORT4__ 1
+ #define __CL_SHORT4__ 1
+ #define __CL_INT2__ 1
+ #define __CL_UINT2__ 1
+ #define __CL_ULONG1__ 1
+ #define __CL_LONG1__ 1
+ #define __CL_FLOAT2__ 1
+#endif
+
+#if defined( __AVX__ )
+ #if defined( __MINGW64__ )
+ #include
+ #else
+ #include
+ #endif
+ #if defined( __GNUC__ )
+ typedef cl_float __cl_float8 __attribute__((vector_size(32)));
+ typedef cl_double __cl_double4 __attribute__((vector_size(32)));
+ #else
+ typedef __m256 __cl_float8;
+ typedef __m256d __cl_double4;
+ #endif
+ #define __CL_FLOAT8__ 1
+ #define __CL_DOUBLE4__ 1
+#endif
+
+/* Define capabilities for anonymous struct members. */
+#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
+#define __CL_HAS_ANON_STRUCT__ 1
+#define __CL_ANON_STRUCT__ __extension__
+#elif defined( _WIN32) && (_MSC_VER >= 1500)
+ /* Microsoft Developer Studio 2008 supports anonymous structs, but
+ * complains by default. */
+#define __CL_HAS_ANON_STRUCT__ 1
+#define __CL_ANON_STRUCT__
+ /* Disable warning C4201: nonstandard extension used : nameless
+ * struct/union */
+#pragma warning( push )
+#pragma warning( disable : 4201 )
+#else
+#define __CL_HAS_ANON_STRUCT__ 0
+#define __CL_ANON_STRUCT__
+#endif
+
+/* Define alignment keys */
+#if defined( __GNUC__ )
+ #define CL_ALIGNED(_x) __attribute__ ((aligned(_x)))
+#elif defined( _WIN32) && (_MSC_VER)
+ /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */
+ /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */
+ /* #include */
+ /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */
+ #define CL_ALIGNED(_x)
+#else
+ #warning Need to implement some method to align data here
+ #define CL_ALIGNED(_x)
+#endif
+
+/* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
+#if __CL_HAS_ANON_STRUCT__
+ /* .xyzw and .s0123...{f|F} are supported */
+ #define CL_HAS_NAMED_VECTOR_FIELDS 1
+ /* .hi and .lo are supported */
+ #define CL_HAS_HI_LO_VECTOR_FIELDS 1
+#endif
+
+/* Define cl_vector types */
+
+/* ---- cl_charn ---- */
+typedef union
+{
+ cl_char CL_ALIGNED(2) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_char lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2;
+#endif
+}cl_char2;
+
+typedef union
+{
+ cl_char CL_ALIGNED(4) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2[2];
+#endif
+#if defined( __CL_CHAR4__)
+ __cl_char4 v4;
+#endif
+}cl_char4;
+
+/* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
+typedef cl_char4 cl_char3;
+
+typedef union
+{
+ cl_char CL_ALIGNED(8) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2[4];
+#endif
+#if defined( __CL_CHAR4__)
+ __cl_char4 v4[2];
+#endif
+#if defined( __CL_CHAR8__ )
+ __cl_char8 v8;
+#endif
+}cl_char8;
+
+typedef union
+{
+ cl_char CL_ALIGNED(16) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2[8];
+#endif
+#if defined( __CL_CHAR4__)
+ __cl_char4 v4[4];
+#endif
+#if defined( __CL_CHAR8__ )
+ __cl_char8 v8[2];
+#endif
+#if defined( __CL_CHAR16__ )
+ __cl_char16 v16;
+#endif
+}cl_char16;
+
+
+/* ---- cl_ucharn ---- */
+typedef union
+{
+ cl_uchar CL_ALIGNED(2) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar lo, hi; };
+#endif
+#if defined( __cl_uchar2__)
+ __cl_uchar2 v2;
+#endif
+}cl_uchar2;
+
+typedef union
+{
+ cl_uchar CL_ALIGNED(4) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; };
+#endif
+#if defined( __CL_UCHAR2__)
+ __cl_uchar2 v2[2];
+#endif
+#if defined( __CL_UCHAR4__)
+ __cl_uchar4 v4;
+#endif
+}cl_uchar4;
+
+/* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
+typedef cl_uchar4 cl_uchar3;
+
+typedef union
+{
+ cl_uchar CL_ALIGNED(8) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; };
+#endif
+#if defined( __CL_UCHAR2__)
+ __cl_uchar2 v2[4];
+#endif
+#if defined( __CL_UCHAR4__)
+ __cl_uchar4 v4[2];
+#endif
+#if defined( __CL_UCHAR8__ )
+ __cl_uchar8 v8;
+#endif
+}cl_uchar8;
+
+typedef union
+{
+ cl_uchar CL_ALIGNED(16) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; };
+#endif
+#if defined( __CL_UCHAR2__)
+ __cl_uchar2 v2[8];
+#endif
+#if defined( __CL_UCHAR4__)
+ __cl_uchar4 v4[4];
+#endif
+#if defined( __CL_UCHAR8__ )
+ __cl_uchar8 v8[2];
+#endif
+#if defined( __CL_UCHAR16__ )
+ __cl_uchar16 v16;
+#endif
+}cl_uchar16;
+
+
+/* ---- cl_shortn ---- */
+typedef union
+{
+ cl_short CL_ALIGNED(4) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_short lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2;
+#endif
+}cl_short2;
+
+typedef union
+{
+ cl_short CL_ALIGNED(8) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2[2];
+#endif
+#if defined( __CL_SHORT4__)
+ __cl_short4 v4;
+#endif
+}cl_short4;
+
+/* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
+typedef cl_short4 cl_short3;
+
+typedef union
+{
+ cl_short CL_ALIGNED(16) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2[4];
+#endif
+#if defined( __CL_SHORT4__)
+ __cl_short4 v4[2];
+#endif
+#if defined( __CL_SHORT8__ )
+ __cl_short8 v8;
+#endif
+}cl_short8;
+
+typedef union
+{
+ cl_short CL_ALIGNED(32) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2[8];
+#endif
+#if defined( __CL_SHORT4__)
+ __cl_short4 v4[4];
+#endif
+#if defined( __CL_SHORT8__ )
+ __cl_short8 v8[2];
+#endif
+#if defined( __CL_SHORT16__ )
+ __cl_short16 v16;
+#endif
+}cl_short16;
+
+
+/* ---- cl_ushortn ---- */
+typedef union
+{
+ cl_ushort CL_ALIGNED(4) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2;
+#endif
+}cl_ushort2;
+
+typedef union
+{
+ cl_ushort CL_ALIGNED(8) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2[2];
+#endif
+#if defined( __CL_USHORT4__)
+ __cl_ushort4 v4;
+#endif
+}cl_ushort4;
+
+/* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
+typedef cl_ushort4 cl_ushort3;
+
+typedef union
+{
+ cl_ushort CL_ALIGNED(16) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2[4];
+#endif
+#if defined( __CL_USHORT4__)
+ __cl_ushort4 v4[2];
+#endif
+#if defined( __CL_USHORT8__ )
+ __cl_ushort8 v8;
+#endif
+}cl_ushort8;
+
+typedef union
+{
+ cl_ushort CL_ALIGNED(32) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2[8];
+#endif
+#if defined( __CL_USHORT4__)
+ __cl_ushort4 v4[4];
+#endif
+#if defined( __CL_USHORT8__ )
+ __cl_ushort8 v8[2];
+#endif
+#if defined( __CL_USHORT16__ )
+ __cl_ushort16 v16;
+#endif
+}cl_ushort16;
+
+/* ---- cl_intn ---- */
+typedef union
+{
+ cl_int CL_ALIGNED(8) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_int lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2;
+#endif
+}cl_int2;
+
+typedef union
+{
+ cl_int CL_ALIGNED(16) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2[2];
+#endif
+#if defined( __CL_INT4__)
+ __cl_int4 v4;
+#endif
+}cl_int4;
+
+/* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
+typedef cl_int4 cl_int3;
+
+typedef union
+{
+ cl_int CL_ALIGNED(32) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2[4];
+#endif
+#if defined( __CL_INT4__)
+ __cl_int4 v4[2];
+#endif
+#if defined( __CL_INT8__ )
+ __cl_int8 v8;
+#endif
+}cl_int8;
+
+typedef union
+{
+ cl_int CL_ALIGNED(64) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2[8];
+#endif
+#if defined( __CL_INT4__)
+ __cl_int4 v4[4];
+#endif
+#if defined( __CL_INT8__ )
+ __cl_int8 v8[2];
+#endif
+#if defined( __CL_INT16__ )
+ __cl_int16 v16;
+#endif
+}cl_int16;
+
+
+/* ---- cl_uintn ---- */
+typedef union
+{
+ cl_uint CL_ALIGNED(8) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_uint lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2;
+#endif
+}cl_uint2;
+
+typedef union
+{
+ cl_uint CL_ALIGNED(16) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2[2];
+#endif
+#if defined( __CL_UINT4__)
+ __cl_uint4 v4;
+#endif
+}cl_uint4;
+
+/* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
+typedef cl_uint4 cl_uint3;
+
+typedef union
+{
+ cl_uint CL_ALIGNED(32) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2[4];
+#endif
+#if defined( __CL_UINT4__)
+ __cl_uint4 v4[2];
+#endif
+#if defined( __CL_UINT8__ )
+ __cl_uint8 v8;
+#endif
+}cl_uint8;
+
+typedef union
+{
+ cl_uint CL_ALIGNED(64) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2[8];
+#endif
+#if defined( __CL_UINT4__)
+ __cl_uint4 v4[4];
+#endif
+#if defined( __CL_UINT8__ )
+ __cl_uint8 v8[2];
+#endif
+#if defined( __CL_UINT16__ )
+ __cl_uint16 v16;
+#endif
+}cl_uint16;
+
+/* ---- cl_longn ---- */
+typedef union
+{
+ cl_long CL_ALIGNED(16) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_long lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2;
+#endif
+}cl_long2;
+
+typedef union
+{
+ cl_long CL_ALIGNED(32) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2[2];
+#endif
+#if defined( __CL_LONG4__)
+ __cl_long4 v4;
+#endif
+}cl_long4;
+
+/* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
+typedef cl_long4 cl_long3;
+
+typedef union
+{
+ cl_long CL_ALIGNED(64) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2[4];
+#endif
+#if defined( __CL_LONG4__)
+ __cl_long4 v4[2];
+#endif
+#if defined( __CL_LONG8__ )
+ __cl_long8 v8;
+#endif
+}cl_long8;
+
+typedef union
+{
+ cl_long CL_ALIGNED(128) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2[8];
+#endif
+#if defined( __CL_LONG4__)
+ __cl_long4 v4[4];
+#endif
+#if defined( __CL_LONG8__ )
+ __cl_long8 v8[2];
+#endif
+#if defined( __CL_LONG16__ )
+ __cl_long16 v16;
+#endif
+}cl_long16;
+
+
+/* ---- cl_ulongn ---- */
+typedef union
+{
+ cl_ulong CL_ALIGNED(16) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2;
+#endif
+}cl_ulong2;
+
+typedef union
+{
+ cl_ulong CL_ALIGNED(32) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2[2];
+#endif
+#if defined( __CL_ULONG4__)
+ __cl_ulong4 v4;
+#endif
+}cl_ulong4;
+
+/* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
+typedef cl_ulong4 cl_ulong3;
+
+typedef union
+{
+ cl_ulong CL_ALIGNED(64) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2[4];
+#endif
+#if defined( __CL_ULONG4__)
+ __cl_ulong4 v4[2];
+#endif
+#if defined( __CL_ULONG8__ )
+ __cl_ulong8 v8;
+#endif
+}cl_ulong8;
+
+typedef union
+{
+ cl_ulong CL_ALIGNED(128) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2[8];
+#endif
+#if defined( __CL_ULONG4__)
+ __cl_ulong4 v4[4];
+#endif
+#if defined( __CL_ULONG8__ )
+ __cl_ulong8 v8[2];
+#endif
+#if defined( __CL_ULONG16__ )
+ __cl_ulong16 v16;
+#endif
+}cl_ulong16;
+
+
+/* --- cl_floatn ---- */
+
+typedef union
+{
+ cl_float CL_ALIGNED(8) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_float lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2;
+#endif
+}cl_float2;
+
+typedef union
+{
+ cl_float CL_ALIGNED(16) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_float2 lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2[2];
+#endif
+#if defined( __CL_FLOAT4__)
+ __cl_float4 v4;
+#endif
+}cl_float4;
+
+/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
+typedef cl_float4 cl_float3;
+
+typedef union
+{
+ cl_float CL_ALIGNED(32) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_float4 lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2[4];
+#endif
+#if defined( __CL_FLOAT4__)
+ __cl_float4 v4[2];
+#endif
+#if defined( __CL_FLOAT8__ )
+ __cl_float8 v8;
+#endif
+}cl_float8;
+
+typedef union
+{
+ cl_float CL_ALIGNED(64) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2[8];
+#endif
+#if defined( __CL_FLOAT4__)
+ __cl_float4 v4[4];
+#endif
+#if defined( __CL_FLOAT8__ )
+ __cl_float8 v8[2];
+#endif
+#if defined( __CL_FLOAT16__ )
+ __cl_float16 v16;
+#endif
+}cl_float16;
+
+/* --- cl_doublen ---- */
+
+typedef union
+{
+ cl_double CL_ALIGNED(16) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_double lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2;
+#endif
+}cl_double2;
+
+typedef union
+{
+ cl_double CL_ALIGNED(32) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2[2];
+#endif
+#if defined( __CL_DOUBLE4__)
+ __cl_double4 v4;
+#endif
+}cl_double4;
+
+/* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
+typedef cl_double4 cl_double3;
+
+typedef union
+{
+ cl_double CL_ALIGNED(64) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2[4];
+#endif
+#if defined( __CL_DOUBLE4__)
+ __cl_double4 v4[2];
+#endif
+#if defined( __CL_DOUBLE8__ )
+ __cl_double8 v8;
+#endif
+}cl_double8;
+
+typedef union
+{
+ cl_double CL_ALIGNED(128) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2[8];
+#endif
+#if defined( __CL_DOUBLE4__)
+ __cl_double4 v4[4];
+#endif
+#if defined( __CL_DOUBLE8__ )
+ __cl_double8 v8[2];
+#endif
+#if defined( __CL_DOUBLE16__ )
+ __cl_double16 v16;
+#endif
+}cl_double16;
+
+/* Macro to facilitate debugging
+ * Usage:
+ * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
+ * The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \"
+ * Each line thereafter of OpenCL C source must end with: \n\
+ * The last line ends in ";
+ *
+ * Example:
+ *
+ * const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\
+ * kernel void foo( int a, float * b ) \n\
+ * { \n\
+ * // my comment \n\
+ * *b[ get_global_id(0)] = a; \n\
+ * } \n\
+ * ";
+ *
+ * This should correctly set up the line, (column) and file information for your source
+ * string so you can do source level debugging.
+ */
+#define __CL_STRINGIFY( _x ) # _x
+#define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
+#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef __CL_HAS_ANON_STRUCT__
+#undef __CL_ANON_STRUCT__
+#if defined( _WIN32) && (_MSC_VER >= 1500)
+#pragma warning( pop )
+#endif
+
+#endif /* __CL_PLATFORM_H */
diff --git a/phonelibs/opencl/include/CL/opencl.h b/phonelibs/opencl/include/CL/opencl.h
new file mode 100644
index 0000000000..9855cd75e7
--- /dev/null
+++ b/phonelibs/opencl/include/CL/opencl.h
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+ * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+ * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ * https://www.khronos.org/registry/
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
+
+#ifndef __OPENCL_H
+#define __OPENCL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __APPLE__
+
+#include
+#include
+#include
+#include
+
+#else
+
+#include
+#include
+#include
+#include
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_H */
+
diff --git a/requirements_openpilot.txt b/requirements_openpilot.txt
index 69f135c260..03459175d4 100644
--- a/requirements_openpilot.txt
+++ b/requirements_openpilot.txt
@@ -15,5 +15,5 @@ sympy==1.1.1
filterpy==1.0.0
smbus2==0.2.0
pyflakes==1.5.0
--e git+https://github.com/commaai/le_python.git#egg=Logentries
+-e git+https://github.com/commaai/le_python.git@5eef8f5be5929d33973e1b10e686fa0cdcd6792f#egg=Logentries
Flask==1.0.1
diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc
index 66eef809a1..669f0fdd8c 100644
--- a/selfdrive/boardd/boardd.cc
+++ b/selfdrive/boardd/boardd.cc
@@ -53,7 +53,7 @@ pthread_mutex_t usb_lock;
bool spoofing_started = false;
bool fake_send = false;
bool loopback_can = false;
-bool has_pigeon = false;
+bool is_grey_panda = false;
pthread_t safety_setter_thread_handle = -1;
pthread_t pigeon_thread_handle = -1;
@@ -173,6 +173,7 @@ bool usb_connect() {
if (is_pigeon[0]) {
LOGW("grey panda detected");
+ is_grey_panda = true;
pigeon_needs_init = true;
if (pigeon_thread_handle == -1) {
err = pthread_create(&pigeon_thread_handle, NULL, pigeon_thread, NULL);
@@ -295,6 +296,7 @@ void can_health(void *s) {
healthData.setControlsAllowed(health.controls_allowed);
healthData.setGasInterceptorDetected(health.gas_interceptor_detected);
healthData.setStartedSignalDetected(health.started_signal_detected);
+ healthData.setIsGreyPanda(is_grey_panda);
// send to health
auto words = capnp::messageToFlatArray(msg);
diff --git a/selfdrive/boardd/boardd.py b/selfdrive/boardd/boardd.py
index 7aca3b8781..849d43979b 100755
--- a/selfdrive/boardd/boardd.py
+++ b/selfdrive/boardd/boardd.py
@@ -104,10 +104,10 @@ def can_init():
handle.controlWrite(0x40, 0xdc, SAFETY_ALLOUTPUT, 0, b'')
if handle is None:
- print "CAN NOT FOUND"
+ cloudlog.warn("CAN NOT FOUND")
exit(-1)
- print "got handle"
+ cloudlog.info("got handle")
cloudlog.info("can init done")
def boardd_mock_loop():
@@ -129,7 +129,7 @@ def boardd_mock_loop():
# recv @ 100hz
can_msgs = can_recv()
- print "sent %d got %d" % (len(snd), len(can_msgs))
+ print("sent %d got %d" % (len(snd), len(can_msgs)))
m = can_list_to_can_capnp(can_msgs)
sendcan.send(m.to_bytes())
@@ -142,7 +142,7 @@ def boardd_test_loop():
#can_send_many([[0xaa,0,"\xaa\xaa\xaa\xaa",1]])
# recv @ 100hz
can_msgs = can_recv()
- print "got %d" % (len(can_msgs))
+ print("got %d" % (len(can_msgs)))
time.sleep(0.01)
cnt += 1
diff --git a/selfdrive/can/packer.py b/selfdrive/can/packer.py
index 5186e17622..58f5e3efc3 100644
--- a/selfdrive/can/packer.py
+++ b/selfdrive/can/packer.py
@@ -1,6 +1,4 @@
import struct
-import numbers
-
from selfdrive.can.libdbc_py import libdbc, ffi
@@ -10,7 +8,6 @@ class CANPacker(object):
self.dbc = libdbc.dbc_lookup(dbc_name)
self.sig_names = {}
self.name_to_address_and_size = {}
- self.address_to_size = {}
num_msgs = self.dbc[0].num_msgs
for i in range(num_msgs):
@@ -19,16 +16,11 @@ class CANPacker(object):
name = ffi.string(msg.name)
address = msg.address
self.name_to_address_and_size[name] = (address, msg.size)
- self.address_to_size[address] = msg.size
+ self.name_to_address_and_size[address] = (address, msg.size)
def pack(self, addr, values, counter):
- # values: [(signal_name, signal_value)]
-
values_thing = []
- if isinstance(values, dict):
- values = values.items()
-
- for name, value in values:
+ for name, value in values.iteritems():
if name not in self.sig_names:
self.sig_names[name] = ffi.new("char[]", name)
@@ -42,10 +34,7 @@ class CANPacker(object):
return libdbc.canpack_pack(self.packer, addr, len(values_thing), values_c, counter)
def pack_bytes(self, addr, values, counter=-1):
- if isinstance(addr, numbers.Number):
- size = self.address_to_size[addr]
- else:
- addr, size = self.name_to_address_and_size[addr]
+ addr, size = self.name_to_address_and_size[addr]
val = self.pack(addr, values, counter)
r = struct.pack(">Q", val)
@@ -62,4 +51,4 @@ if __name__ == "__main__":
("PCM_SPEED", 123),
("PCM_GAS", 10),
])
- print s[1].encode("hex")
+ print(s[1].encode("hex"))
diff --git a/selfdrive/can/parser.py b/selfdrive/can/parser.py
index c4c007d1f5..6abbb3c18a 100644
--- a/selfdrive/can/parser.py
+++ b/selfdrive/can/parser.py
@@ -203,6 +203,6 @@ if __name__ == "__main__":
while True:
cp.update(int(sec_since_boot()*1e9), True)
# print cp.vl
- print cp.ts
- print cp.can_valid
+ print(cp.ts)
+ print(cp.can_valid)
time.sleep(0.01)
diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py
index 0255137ab0..afe5a9e4c1 100644
--- a/selfdrive/car/car_helpers.py
+++ b/selfdrive/car/car_helpers.py
@@ -1,4 +1,5 @@
import os
+import time
from common.basedir import BASEDIR
from common.realtime import sec_since_boot
from common.fingerprints import eliminate_incompatible_cars, all_known_cars
@@ -49,18 +50,20 @@ def fingerprint(logcan, timeout):
candidate_cars = all_known_cars()
finger = {}
st = None
+ st_passive = sec_since_boot() # only relevant when passive
+ can_seen = False
while 1:
- for a in messaging.drain_sock(logcan, wait_for_one=True):
+ for a in messaging.drain_sock(logcan):
for can in a.can:
+ can_seen = True
# ignore everything not on bus 0 and with more than 11 bits,
# which are ussually sporadic and hard to include in fingerprints
if can.src == 0 and can.address < 0x800:
finger[can.address] = len(can.dat)
candidate_cars = eliminate_incompatible_cars(can, candidate_cars)
- if st is None:
+ if st is None and can_seen:
st = sec_since_boot() # start time
- st_passive = sec_since_boot() # only relevant when passive
ts = sec_since_boot()
# if we only have one car choice and the time_fingerprint since we got our first
# message has elapsed, exit. Toyota needs higher time_fingerprint, since DSU does not
@@ -75,13 +78,15 @@ def fingerprint(logcan, timeout):
elif len(candidate_cars) == 0 or (timeout and (ts - st_passive) > timeout):
return None, finger
+ time.sleep(0.01)
+
cloudlog.warning("fingerprinted %s", candidate_cars[0])
return (candidate_cars[0], finger)
def get_car(logcan, sendcan=None, passive=True):
# TODO: timeout only useful for replays so controlsd can start before unlogger
- timeout = 1. if passive else None
+ timeout = 2. if passive else None
candidate, fingerprints = fingerprint(logcan, timeout)
if candidate is None:
@@ -93,7 +98,7 @@ def get_car(logcan, sendcan=None, passive=True):
interface_cls = interfaces[candidate]
if interface_cls is None:
- cloudlog.warning("car matched %s, but interface wasn't available" % candidate)
+ cloudlog.warning("car matched %s, but interface wasn't available or failed to import" % candidate)
return None, None
params = interface_cls.get_params(candidate, fingerprints)
diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py
index f4163f526d..6a64183425 100755
--- a/selfdrive/car/ford/interface.py
+++ b/selfdrive/car/ford/interface.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
from common.realtime import sec_since_boot
from cereal import car
+from selfdrive.swaglog import cloudlog
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
@@ -75,6 +76,7 @@ class CarInterface(object):
ret.steerKpV, ret.steerKiV = [[0.01], [0.005]] # TODO: tune this
ret.steerKf = 1. / MAX_ANGLE # MAX Steer angle to normalize FF
ret.steerActuatorDelay = 0.1 # Default delay, not measured yet
+ ret.steerRateCost = 1.0
f = 1.2
tireStiffnessFront_civic *= f
@@ -117,7 +119,7 @@ class CarInterface(object):
ret.brakeMaxV = [1., 0.8]
ret.enableCamera = not any(x for x in [970, 973, 984] if x in fingerprint)
- print "ECU Camera Simulated: ", ret.enableCamera
+ cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera)
ret.steerLimitAlert = False
ret.stoppingControl = False
diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py
index 3f53291f99..53dc8b68e7 100755
--- a/selfdrive/car/gm/interface.py
+++ b/selfdrive/car/gm/interface.py
@@ -151,6 +151,7 @@ class CarInterface(object):
ret.startAccel = 0.8
ret.steerActuatorDelay = 0.1 # Default delay, not measured yet
+ ret.steerRateCost = 1.0
ret.steerControlType = car.CarParams.SteerControlType.torque
return ret
diff --git a/selfdrive/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py
index 1a91a06bd3..0875a67234 100644
--- a/selfdrive/car/honda/carcontroller.py
+++ b/selfdrive/car/honda/carcontroller.py
@@ -6,7 +6,6 @@ from selfdrive.car.honda import hondacan
from selfdrive.car.honda.values import AH, CruiseButtons, CAR
from selfdrive.can.packer import CANPacker
-
def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint):
# hyst params... TODO: move these to VehicleParams
brake_hyst_on = 0.02 # to activate brakes exceed this value
@@ -109,7 +108,6 @@ class CarController(object):
0xc1, hud_lanes, int(snd_beep), snd_chime, fcw_display, acc_alert, steer_required)
if not all(isinstance(x, int) and 0 <= x < 256 for x in hud):
- print "INVALID HUD", hud
hud = HUDData(0xc6, 255, 64, 0xc0, 209, 0x40, 0, 0, 0, 0)
# **** process the car messages ****
diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py
index b926c156c6..36dea1f7ff 100644
--- a/selfdrive/car/honda/carstate.py
+++ b/selfdrive/car/honda/carstate.py
@@ -3,8 +3,6 @@ from common.kalman.simple_kalman import KF1D
from selfdrive.can.parser import CANParser
from selfdrive.config import Conversions as CV
from selfdrive.car.honda.values import CAR, DBC
-import numpy as np
-
def parse_gear_shifter(can_gear_shifter, car_fingerprint):
@@ -73,7 +71,6 @@ def get_can_signals(CP):
("LEFT_BLINKER", "SCM_FEEDBACK", 0),
("RIGHT_BLINKER", "SCM_FEEDBACK", 0),
("GEAR", "GEARBOX", 0),
- ("WHEELS_MOVING", "STANDSTILL", 1),
("BRAKE_ERROR_1", "STANDSTILL", 1),
("BRAKE_ERROR_2", "STANDSTILL", 1),
("SEATBELT_DRIVER_LAMP", "SEATBELT_STATUS", 1),
@@ -128,8 +125,10 @@ def get_can_signals(CP):
signals += [("DOOR_OPEN_FL", "DOORS_STATUS", 1),
("DOOR_OPEN_FR", "DOORS_STATUS", 1),
("DOOR_OPEN_RL", "DOORS_STATUS", 1),
- ("DOOR_OPEN_RR", "DOORS_STATUS", 1)]
+ ("DOOR_OPEN_RR", "DOORS_STATUS", 1),
+ ("WHEELS_MOVING", "STANDSTILL", 1)]
checks += [("DOORS_STATUS", 3)]
+
if CP.carFingerprint == CAR.CIVIC:
signals += [("CAR_GAS", "GAS_PEDAL_2", 0),
("MAIN_ON", "SCM_FEEDBACK", 0),
@@ -188,10 +187,10 @@ class CarState(object):
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_kf = KF1D(x0=[[0.0], [0.0]],
+ A=[[1.0, dt], [0.0, 1.0]],
+ C=[[1.0, 0.0]],
+ K=[[0.12287673], [0.29666309]])
self.v_ego = 0.0
def update(self, cp):
@@ -212,9 +211,12 @@ class CarState(object):
self.prev_right_blinker_on = self.right_blinker_on
# ******************* parse out can *******************
- if self.CP.carFingerprint in (CAR.ACCORD):
+
+ if self.CP.carFingerprint == CAR.ACCORD: # TODO: find wheels moving bit in dbc
+ self.standstill = cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] < 0.1
self.door_all_closed = not cp.vl["SCM_FEEDBACK"]['DRIVERS_DOOR_OPEN']
else:
+ self.standstill = not cp.vl["STANDSTILL"]['WHEELS_MOVING']
self.door_all_closed = not any([cp.vl["DOORS_STATUS"]['DOOR_OPEN_FL'], cp.vl["DOORS_STATUS"]['DOOR_OPEN_FR'],
cp.vl["DOORS_STATUS"]['DOOR_OPEN_RL'], cp.vl["DOORS_STATUS"]['DOOR_OPEN_RR']])
self.seatbelt = not cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_LAMP'] and cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_LATCHED']
@@ -232,14 +234,14 @@ class CarState(object):
self.v_wheel_fr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FR'] * CV.KPH_TO_MS
self.v_wheel_rl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RL'] * CV.KPH_TO_MS
self.v_wheel_rr = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_RR'] * CV.KPH_TO_MS
- self.v_wheel = float(np.mean([self.v_wheel_fl, self.v_wheel_fr, self.v_wheel_rl, self.v_wheel_rr]))
+ self.v_wheel = (self.v_wheel_fl+self.v_wheel_fr+self.v_wheel_rl+self.v_wheel_rr)/4.
# blend in transmission speed at low speed, since it has more low speed accuracy
self.v_weight = interp(self.v_wheel, v_weight_bp, v_weight_v)
speed = (1. - self.v_weight) * cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] * CV.KPH_TO_MS + self.v_weight * self.v_wheel
if abs(speed - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed
- self.v_ego_x = np.matrix([[speed], [0.0]])
+ self.v_ego_x = [[speed], [0.0]]
self.v_ego_raw = speed
v_ego_x = self.v_ego_kf.update(speed)
@@ -283,10 +285,8 @@ class CarState(object):
self.car_gas = cp.vl["GAS_PEDAL_2"]['CAR_GAS']
#rdx has different steer override threshold
- if self.CP.carFingerprint in (CAR.ACURA_RDX):
- self.steer_override = abs(cp.vl["STEER_STATUS"]['STEER_TORQUE_SENSOR']) > 400
- else:
- self.steer_override = abs(cp.vl["STEER_STATUS"]['STEER_TORQUE_SENSOR']) > 1200
+ steer_thrsld = 400 if self.CP.carFingerprint == CAR.ACURA_RDX else 1200
+ self.steer_override = abs(cp.vl["STEER_STATUS"]['STEER_TORQUE_SENSOR']) > steer_thrsld
self.steer_torque_driver = cp.vl["STEER_STATUS"]['STEER_TORQUE_SENSOR']
self.brake_switch = cp.vl["POWERTRAIN_DATA"]['BRAKE_SWITCH']
@@ -319,7 +319,6 @@ class CarState(object):
self.brake_switch_ts = cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH']
self.user_brake = cp.vl["VSA_STATUS"]['USER_BRAKE']
- self.standstill = not cp.vl["STANDSTILL"]['WHEELS_MOVING']
self.pcm_acc_status = cp.vl["POWERTRAIN_DATA"]['ACC_STATUS']
self.hud_lead = cp.vl["ACC_HUD"]['HUD_LEAD']
diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py
index 32c32a64f8..db02a9725a 100755
--- a/selfdrive/car/honda/interface.py
+++ b/selfdrive/car/honda/interface.py
@@ -4,6 +4,7 @@ import numpy as np
from cereal import car
from common.numpy_fast import clip, interp
from common.realtime import sec_since_boot
+from selfdrive.swaglog import cloudlog
from selfdrive.config import Conversions as CV
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET, get_events
from selfdrive.controls.lib.vehicle_model import VehicleModel
@@ -132,14 +133,7 @@ class CarInterface(object):
@staticmethod
def get_params(candidate, fingerprint):
- # kg of standard extra cargo to count for drive, gas, etc...
- std_cargo = 136
-
- # Ridgeline reqires scaled tire stiffness
- ts_factor = 1
-
ret = car.CarParams.new_message()
-
ret.carName = "honda"
ret.carFingerprint = candidate
@@ -151,11 +145,14 @@ class CarInterface(object):
ret.safetyModel = car.CarParams.SafetyModels.honda
ret.enableCamera = not any(x for x in CAMERA_MSGS if x in fingerprint)
ret.enableGasInterceptor = 0x201 in fingerprint
- print "ECU Camera Simulated: ", ret.enableCamera
- print "ECU Gas Interceptor: ", ret.enableGasInterceptor
+ cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera)
+ cloudlog.warn("ECU Gas Interceptor: %r", ret.enableGasInterceptor)
ret.enableCruise = not ret.enableGasInterceptor
+ # kg of standard extra cargo to count for drive, gas, etc...
+ std_cargo = 136
+
# FIXME: hardcoding honda civic 2016 touring params so they can be used to
# scale unknown params for other cars
mass_civic = 2923 * CV.LB_TO_KG + std_cargo
@@ -163,141 +160,163 @@ class CarInterface(object):
centerToFront_civic = wheelbase_civic * 0.4
centerToRear_civic = wheelbase_civic - centerToFront_civic
rotationalInertia_civic = 2500
- tireStiffnessFront_civic = 85400
- tireStiffnessRear_civic = 90000
+ tireStiffnessFront_civic = 192150
+ tireStiffnessRear_civic = 202500
+
+ # Optimized car params: tire_stiffness_factor and steerRatio are a result of a vehicle
+ # model optimization process. Certain Hondas have an extra steering sensor at the bottom
+ # of the steering rack, which improves controls quality as it removes the steering column
+ # torsion from feedback.
+ # Tire stiffness factor fictitiously lower if it includes the steering column torsion effect.
+ # For modeling details, see p.198-200 in "The Science of Vehicle Dynamics (2014), M. Guiggiani"
ret.steerKiBP, ret.steerKpBP = [[0.], [0.]]
+
+ ret.steerKf = 0.00006 # conservative feed-forward
+
if candidate == CAR.CIVIC:
stop_and_go = True
ret.mass = mass_civic
ret.wheelbase = wheelbase_civic
ret.centerToFront = centerToFront_civic
- ret.steerRatio = 13.0
+ ret.steerRatio = 14.63 # 10.93 is end-to-end spec
+ 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.4], [0.12]] if is_fw_modified else [[0.8], [0.24]]
-
+ ret.steerKpV, ret.steerKiV = [[0.33], [0.10]] if is_fw_modified else [[0.8], [0.24]]
+ if is_fw_modified:
+ ret.steerKf = 0.00003
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_HATCH:
stop_and_go = True
ret.mass = 2916. * CV.LB_TO_KG + std_cargo
ret.wheelbase = wheelbase_civic
ret.centerToFront = centerToFront_civic
- ret.steerRatio = 10.93
+ 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 == CAR.ACCORD:
stop_and_go = True
ret.safetyParam = 1 # Accord and CRV 5G use an alternate user brake msg
ret.mass = 3279. * CV.LB_TO_KG + std_cargo
ret.wheelbase = 2.83
ret.centerToFront = ret.wheelbase * 0.39
- ret.steerRatio = 11.82
- ret.steerKpV, ret.steerKiV = [[0.8], [0.24]]
-
+ ret.steerRatio = 15.96 # 11.82 is spec end-to-end
+ tire_stiffness_factor = 0.8467
+ ret.steerKpV, ret.steerKiV = [[0.6], [0.18]]
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 == CAR.ACURA_ILX:
stop_and_go = False
ret.mass = 3095 * CV.LB_TO_KG + std_cargo
ret.wheelbase = 2.67
ret.centerToFront = ret.wheelbase * 0.37
- ret.steerRatio = 15.3
+ 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.4], [0.12]] if is_fw_modified else [[0.8], [0.24]]
-
+ 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.longitudinalKpBP = [0., 5., 35.]
ret.longitudinalKpV = [1.2, 0.8, 0.5]
ret.longitudinalKiBP = [0., 35.]
ret.longitudinalKiV = [0.18, 0.12]
+
elif candidate == CAR.CRV:
stop_and_go = False
ret.mass = 3572 * CV.LB_TO_KG + std_cargo
ret.wheelbase = 2.62
ret.centerToFront = ret.wheelbase * 0.41
- ret.steerRatio = 15.3
+ ret.steerRatio = 15.3 # as spec
+ tire_stiffness_factor = 0.444 # not optimized yet
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 == CAR.CRV_5G:
stop_and_go = True
ret.safetyParam = 1 # Accord and CRV 5G use an alternate user brake msg
ret.mass = 3410. * CV.LB_TO_KG + std_cargo
ret.wheelbase = 2.66
ret.centerToFront = ret.wheelbase * 0.41
- ret.steerRatio = 12.30
+ ret.steerRatio = 16.0 # 12.3 is spec end-to-end
+ tire_stiffness_factor = 0.677
ret.steerKpV, ret.steerKiV = [[0.6], [0.18]]
-
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 == CAR.ACURA_RDX:
stop_and_go = False
ret.mass = 3935 * CV.LB_TO_KG + std_cargo
ret.wheelbase = 2.68
ret.centerToFront = ret.wheelbase * 0.38
- ret.steerRatio = 15.0
+ ret.steerRatio = 15.0 # as spec
+ tire_stiffness_factor = 0.444 # not optimized yet
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 == CAR.ODYSSEY:
stop_and_go = False
ret.mass = 4354 * CV.LB_TO_KG + std_cargo
ret.wheelbase = 3.00
ret.centerToFront = ret.wheelbase * 0.41
- ret.steerRatio = 14.35
+ ret.steerRatio = 14.35 # as spec
+ tire_stiffness_factor = 0.444 # not optimized yet
ret.steerKpV, ret.steerKiV = [[0.6], [0.18]]
-
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 == CAR.PILOT:
stop_and_go = False
ret.mass = 4303 * CV.LB_TO_KG + std_cargo
ret.wheelbase = 2.81
ret.centerToFront = ret.wheelbase * 0.41
- ret.steerRatio = 16.0
+ ret.steerRatio = 16.0 # as spec
+ tire_stiffness_factor = 0.444 # not optimized yet
ret.steerKpV, ret.steerKiV = [[0.38], [0.11]]
-
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 == CAR.RIDGELINE:
stop_and_go = False
- ts_factor = 1.4
ret.mass = 4515 * CV.LB_TO_KG + std_cargo
ret.wheelbase = 3.18
ret.centerToFront = ret.wheelbase * 0.41
- ret.steerRatio = 15.59
+ ret.steerRatio = 15.59 # as spec
+ tire_stiffness_factor = 0.444 # not optimized yet
ret.steerKpV, ret.steerKiV = [[0.38], [0.11]]
-
ret.longitudinalKpBP = [0., 5., 35.]
ret.longitudinalKpV = [1.2, 0.8, 0.5]
ret.longitudinalKiBP = [0., 35.]
ret.longitudinalKiV = [0.18, 0.12]
+
else:
raise ValueError("unsupported car %s" % candidate)
- ret.steerKf = 0. # TODO: investigate FF steer control for Honda
ret.steerControlType = car.CarParams.SteerControlType.torque
# min speed to enable ACC. if car can do stop and go, then set enabling speed
@@ -313,10 +332,10 @@ class CarInterface(object):
# 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 * ts_factor) * \
+ ret.tireStiffnessFront = (tireStiffnessFront_civic * tire_stiffness_factor) * \
ret.mass / mass_civic * \
(centerToRear / ret.wheelbase) / (centerToRear_civic / wheelbase_civic)
- ret.tireStiffnessRear = (tireStiffnessRear_civic * ts_factor) * \
+ ret.tireStiffnessRear = (tireStiffnessRear_civic * tire_stiffness_factor) * \
ret.mass / mass_civic * \
(ret.centerToFront / ret.wheelbase) / (centerToFront_civic / wheelbase_civic)
@@ -339,7 +358,8 @@ class CarInterface(object):
ret.steerLimitAlert = True
ret.startAccel = 0.5
- ret.steerActuatorDelay = 0.09
+ ret.steerActuatorDelay = 0.1
+ ret.steerRateCost = 0.5
return ret
@@ -465,7 +485,7 @@ class CarInterface(object):
if self.CS.steer_error:
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
elif self.CS.steer_warning:
- events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING]))
+ events.append(create_event('steerTempUnavailable', [ET.WARNING]))
if self.CS.brake_error:
events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
if not ret.gearShifter == 'drive':
@@ -514,7 +534,6 @@ class CarInterface(object):
# do enable on both accel and decel buttons
if b.type in ["accelCruise", "decelCruise"] and not b.pressed:
- print "enabled pressed at", cur_time
self.last_enable_pressed = cur_time
enable_pressed = True
diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py
index 3b3f0bab05..b15a90a6e2 100644
--- a/selfdrive/car/honda/values.py
+++ b/selfdrive/car/honda/values.py
@@ -54,42 +54,42 @@ FINGERPRINTS = {
148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 387: 8, 388: 8, 399: 7, 419: 8, 420: 8, 427: 3, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 525: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8
}],
CAR.ACURA_ILX: [{
- 1024L: 5, 513L: 6, 1027L: 5, 1029L: 8, 929L: 4, 1057L: 5, 777L: 8, 1034L: 5, 1036L: 8, 398L: 3, 399L: 7, 145L: 8, 660L: 8, 985L: 3, 923L: 2, 542L: 7, 773L: 7, 800L: 8, 432L: 7, 419L: 8, 420L: 8, 1030L: 5, 422L: 8, 808L: 8, 428L: 8, 304L: 8, 819L: 7, 821L: 5, 57L: 3, 316L: 8, 545L: 4, 464L: 8, 1108L: 8, 597L: 8, 342L: 6, 983L: 8, 344L: 8, 804L: 8, 1039L: 8, 476L: 4, 892L: 8, 490L: 8, 1064L: 7, 882L: 2, 884L: 7, 887L: 8, 888L: 8, 380L: 8, 1365L: 5,
+ 1024: 5, 513: 6, 1027: 5, 1029: 8, 929: 4, 1057: 5, 777: 8, 1034: 5, 1036: 8, 398: 3, 399: 7, 145: 8, 660: 8, 985: 3, 923: 2, 542: 7, 773: 7, 800: 8, 432: 7, 419: 8, 420: 8, 1030: 5, 422: 8, 808: 8, 428: 8, 304: 8, 819: 7, 821: 5, 57: 3, 316: 8, 545: 4, 464: 8, 1108: 8, 597: 8, 342: 6, 983: 8, 344: 8, 804: 8, 1039: 8, 476: 4, 892: 8, 490: 8, 1064: 7, 882: 2, 884: 7, 887: 8, 888: 8, 380: 8, 1365: 5,
# sent messages
0xe4: 5, 0x1fa: 8, 0x200: 6, 0x30c: 8, 0x33d: 5,
}],
CAR.ACURA_RDX: [{
- 57L: 3, 145L: 8, 229L: 4, 308L: 5, 316L: 8, 342L: 6, 344L: 8, 380L: 8, 392L: 6, 398L: 3, 399L: 6, 404L: 4, 420L: 8, 422L: 8, 426L: 8, 432L: 7, 464L: 8, 474L: 5, 476L: 4, 487L: 4, 490L: 8, 506L: 8, 542L: 7, 545L: 4, 597L: 8, 660L: 8, 773L: 7, 777L: 8, 780L: 8, 800L: 8, 804L: 8, 808L: 8, 819L: 7, 821L: 5, 829L: 5, 882L: 2, 884L: 7, 887L: 8, 888L: 8, 892L: 8, 923L: 2, 929L: 4, 963L: 8, 965L: 8, 966L: 8, 967L: 8, 983L: 8, 985L: 3, 1024L: 5, 1027L: 5, 1029L: 8, 1033L: 5, 1034L: 5, 1036L: 8, 1039L: 8, 1057L: 5, 1064L: 7, 1108L: 8, 1365L: 5, 1424L: 5, 1729L: 1
+ 57: 3, 145: 8, 229: 4, 308: 5, 316: 8, 342: 6, 344: 8, 380: 8, 392: 6, 398: 3, 399: 6, 404: 4, 420: 8, 422: 8, 426: 8, 432: 7, 464: 8, 474: 5, 476: 4, 487: 4, 490: 8, 506: 8, 542: 7, 545: 4, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 882: 2, 884: 7, 887: 8, 888: 8, 892: 8, 923: 2, 929: 4, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1033: 5, 1034: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1365: 5, 1424: 5, 1729: 1
}],
CAR.CIVIC: [{
- 1024L: 5, 513L: 6, 1027L: 5, 1029L: 8, 777L: 8, 1036L: 8, 1039L: 8, 1424L: 5, 401L: 8, 148L: 8, 662L: 4, 985L: 3, 795L: 8, 773L: 7, 800L: 8, 545L: 6, 420L: 8, 806L: 8, 808L: 8, 1322L: 5, 427L: 3, 428L: 8, 304L: 8, 432L: 7, 57L: 3, 450L: 8, 929L: 8, 330L: 8, 1302L: 8, 464L: 8, 1361L: 5, 1108L: 8, 597L: 8, 470L: 2, 344L: 8, 804L: 8, 399L: 7, 476L: 7, 1633L: 8, 487L: 4, 892L: 8, 490L: 8, 493L: 5, 884L: 8, 891L: 8, 380L: 8, 1365L: 5,
+ 1024: 5, 513: 6, 1027: 5, 1029: 8, 777: 8, 1036: 8, 1039: 8, 1424: 5, 401: 8, 148: 8, 662: 4, 985: 3, 795: 8, 773: 7, 800: 8, 545: 6, 420: 8, 806: 8, 808: 8, 1322: 5, 427: 3, 428: 8, 304: 8, 432: 7, 57: 3, 450: 8, 929: 8, 330: 8, 1302: 8, 464: 8, 1361: 5, 1108: 8, 597: 8, 470: 2, 344: 8, 804: 8, 399: 7, 476: 7, 1633: 8, 487: 4, 892: 8, 490: 8, 493: 5, 884: 8, 891: 8, 380: 8, 1365: 5,
# sent messages
0xe4: 5, 0x1fa: 8, 0x200: 6, 0x30c: 8, 0x33d: 5, 0x35e: 8, 0x39f: 8,
}],
CAR.CIVIC_HATCH: [{
- 57L: 3, 148L: 8, 228L: 5, 304L: 8, 330L: 8, 344L: 8, 380L: 8, 399L: 7, 401L: 8, 420L: 8, 427L: 3, 428L: 8, 432L: 7, 441L: 5, 450L: 8, 464L: 8, 470L: 2, 476L: 7, 477L: 8, 479L: 8, 490L: 8, 493L: 5, 495L: 8, 506L: 8, 545L: 6, 597L: 8, 662L: 4, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 806L: 8, 808L: 8, 829L: 5, 862L: 8, 884L: 8, 891L: 8, 892L: 8, 927L: 8, 929L: 8, 985L: 3, 1024L: 5, 1027L: 5, 1029L: 8, 1036L: 8, 1039L: 8, 1108L: 8, 1302L: 8, 1322L: 5, 1361L: 5, 1365L: 5, 1424L: 5, 1600L: 5, 1601L: 8, 1633L: 8
+ 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1633: 8
}],
CAR.CRV: [{
- 57L: 3, 145L: 8, 316L: 8, 340L: 8, 342L: 6, 344L: 8, 380L: 8, 398L: 3, 399L: 6, 401L: 8, 420L: 8, 422L: 8, 426L: 8, 432L: 7, 464L: 8, 474L: 5, 476L: 4, 487L: 4, 490L: 8, 493L: 3, 507L: 1, 542L: 7, 545L: 4, 597L: 8, 660L: 8, 661L: 4, 773L: 7, 777L: 8, 800L: 8, 804L: 8, 808L: 8, 882L: 2, 884L: 7, 888L: 8, 891L: 8, 892L: 8, 923L: 2, 929L: 8, 983L: 8, 985L: 3, 1024L: 5, 1027L: 5, 1029L: 8, 1033L: 5, 1036L: 8, 1039L: 8, 1057L: 5, 1064L: 7, 1108L: 8, 1125L: 8, 1296L: 8, 1365L: 5, 1424L: 5, 1600L: 5, 1601L: 8,
+ 57: 3, 145: 8, 316: 8, 340: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 6, 401: 8, 420: 8, 422: 8, 426: 8, 432: 7, 464: 8, 474: 5, 476: 4, 487: 4, 490: 8, 493: 3, 507: 1, 542: 7, 545: 4, 597: 8, 660: 8, 661: 4, 773: 7, 777: 8, 800: 8, 804: 8, 808: 8, 882: 2, 884: 7, 888: 8, 891: 8, 892: 8, 923: 2, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1033: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1125: 8, 1296: 8, 1365: 5, 1424: 5, 1600: 5, 1601: 8,
# sent messages
0x194: 4, 0x1fa: 8, 0x30c: 8, 0x33d: 5,
}],
CAR.CRV_5G: [{
- 57L: 3, 148L: 8, 199L: 4, 228L: 5, 231L: 5, 232L: 7, 304L: 8, 330L: 8, 340L: 8, 344L: 8, 380L: 8, 399L: 7, 401L: 8, 420L: 8, 423L: 2, 427L: 3, 428L: 8, 432L: 7, 441L: 5, 446L: 3, 450L: 8, 464L: 8, 467L: 2, 469L: 3, 470L: 2, 474L: 8, 476L: 7, 477L: 8, 479L: 8, 490L: 8, 493L: 5, 495L: 8, 507L: 1, 545L: 6, 597L: 8, 661L: 4, 662L: 4, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 806L: 8, 808L: 8, 814L: 4, 815L: 8, 817L: 4, 825L: 4, 829L: 5, 862L: 8, 881L: 8, 882L: 4, 884L: 8, 888L: 8, 891L: 8, 927L: 8, 918L: 7, 929L: 8, 983L: 8, 985L: 3, 1024L: 5, 1027L: 5, 1029L: 8, 1036L: 8, 1039L: 8, 1064L: 7, 1108L: 8, 1092L: 1, 1115L: 4, 1125L: 8, 1127L: 2, 1296L: 8, 1302L: 8, 1322L: 5, 1361L: 5, 1365L: 5, 1424L: 5, 1600L: 5, 1601L: 8, 1618L: 5, 1633L: 8, 1670L: 5
+ 57: 3, 148: 8, 199: 4, 228: 5, 231: 5, 232: 7, 304: 8, 330: 8, 340: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 467: 2, 469: 3, 470: 2, 474: 8, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 507: 1, 545: 6, 597: 8, 661: 4, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 814: 4, 815: 8, 817: 4, 825: 4, 829: 5, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 927: 8, 918: 7, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1108: 8, 1092: 1, 1115: 4, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1618: 5, 1633: 8, 1670: 5
}],
CAR.ODYSSEY: [{
- 57L: 3, 148L: 8, 228L: 5, 229L: 4, 316L: 8, 342L: 6, 344L: 8, 380L: 8, 399L: 7, 411L: 5, 419L: 8, 420L: 8, 427L: 3, 432L: 7, 450L: 8, 463L: 8, 464L: 8, 476L: 4, 490L: 8, 506L: 8, 542L: 7, 545L: 6, 597L: 8, 662L: 4, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 806L: 8, 808L: 8, 817L: 4, 819L: 7, 821L: 5, 825L: 4, 829L: 5, 837L: 5, 856L: 7, 862L: 8, 871L: 8, 881L: 8, 882L: 4, 884L: 8, 891L: 8, 892L: 8, 905L: 8, 923L: 2, 927L: 8, 929L: 8, 963L: 8, 965L: 8, 966L: 8, 967L: 8, 983L: 8, 985L: 3, 1029L: 8, 1036L: 8, 1052L: 8, 1064L: 7, 1088L: 8, 1089L: 8, 1092L: 1, 1108L: 8, 1110L: 8, 1125L: 8, 1296L: 8, 1302L: 8, 1600L: 5, 1601L: 8, 1612L: 5, 1613L: 5, 1614L: 5, 1615L: 8, 1616L: 5, 1619L: 5, 1623L: 5, 1668L: 5
+ 57: 3, 148: 8, 228: 5, 229: 4, 316: 8, 342: 6, 344: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 427: 3, 432: 7, 450: 8, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 542: 7, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 862: 8, 871: 8, 881: 8, 882: 4, 884: 8, 891: 8, 892: 8, 905: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1029: 8, 1036: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1302: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1615: 8, 1616: 5, 1619: 5, 1623: 5, 1668: 5
},
# Odyssey Elite
{
- 57L: 3, 148L: 8, 228L: 5, 229L: 4, 304L: 8, 342L: 6, 344L: 8, 380L: 8, 399L: 7, 411L: 5, 419L: 8, 420L: 8, 427L: 3, 432L: 7, 440L: 8, 450L: 8, 463L: 8, 464L: 8, 476L: 4, 490L: 8, 506L: 8, 507L: 1, 542L: 7, 545L: 6, 597L: 8, 662L: 4, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 806L: 8, 808L: 8, 817L: 4, 819L: 7, 821L: 5, 825L: 4, 829L: 5, 837L: 5, 856L: 7, 862L: 8, 871L: 8, 881L: 8, 882L: 4, 884L: 8, 891L: 8, 892L: 8, 905L: 8, 923L: 2, 927L: 8, 929L: 8, 963L: 8, 965L: 8, 966L: 8, 967L: 8, 983L: 8, 985L: 3, 1029L: 8, 1036L: 8, 1052L: 8, 1064L: 7, 1088L: 8, 1089L: 8, 1092L: 1, 1108L: 8, 1110L: 8, 1125L: 8, 1296L: 8, 1302L: 8, 1600L: 5, 1601L: 8, 1612L: 5, 1613L: 5, 1614L: 5, 1616L: 5, 1619L: 5, 1623L: 5, 1668L: 5
+ 57: 3, 148: 8, 228: 5, 229: 4, 304: 8, 342: 6, 344: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 427: 3, 432: 7, 440: 8, 450: 8, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 507: 1, 542: 7, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 862: 8, 871: 8, 881: 8, 882: 4, 884: 8, 891: 8, 892: 8, 905: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1029: 8, 1036: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1302: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1616: 5, 1619: 5, 1623: 5, 1668: 5
}],
# Includes 2017 Touring and 2016 EX-L messaging.
CAR.PILOT: [{
- 57L: 3, 145L: 8, 228L: 5, 229L: 4, 308L: 5, 316L: 8, 334L: 8, 339L: 7, 342L: 6, 344L: 8, 379L: 8, 380L: 8, 392L: 6, 399L: 7, 419L: 8, 420L: 8, 422L: 8, 425L: 8, 426L: 8, 427L: 3, 432L: 7, 463L: 8, 464L: 8, 476L: 4, 490L: 8, 506L: 8, 507L: 1, 538L: 3, 542L: 7, 545L: 5, 546L: 3, 597L: 8, 660L: 8, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 808L: 8, 819L: 7, 821L: 5, 829L: 5, 837L: 5, 856L: 7, 871L: 8, 882L: 2, 884L: 7, 891L: 8, 892L: 8, 923L: 2, 929L: 8, 963L: 8, 965L: 8, 966L: 8, 967L: 8, 983L: 8, 985L: 3, 1027L: 5, 1029L: 8, 1036L: 8, 1039L: 8, 1064L: 7, 1088L: 8, 1089L: 8, 1108L: 8, 1125L: 8, 1296L: 8, 1424L: 5, 1600L: 5, 1601L: 8, 1612L: 5, 1613L: 5, 1616L: 5, 1618L: 5, 1668L: 5
+ 57: 3, 145: 8, 228: 5, 229: 4, 308: 5, 316: 8, 334: 8, 339: 7, 342: 6, 344: 8, 379: 8, 380: 8, 392: 6, 399: 7, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 507: 1, 538: 3, 542: 7, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 837: 5, 856: 7, 871: 8, 882: 2, 884: 7, 891: 8, 892: 8, 923: 2, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1088: 8, 1089: 8, 1108: 8, 1125: 8, 1296: 8, 1424: 5, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1616: 5, 1618: 5, 1668: 5
}],
CAR.RIDGELINE: [{
- 57L: 3, 145L: 8, 228L: 5, 229L: 4, 308L: 5, 316L: 8, 339L: 7, 342L: 6, 344L: 8, 380L: 8, 392L: 6, 399L: 7, 419L: 8, 420L: 8, 422L: 8, 425L: 8, 426L: 8, 427L: 3, 432L: 7, 464L: 8, 471L: 3, 476L: 4, 490L: 8, 506L: 8, 545L: 5, 546L: 3, 597L: 8, 660L: 8, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 808L: 8, 819L: 7, 821L: 5, 829L: 5, 871L: 8, 882L: 2, 884L: 7, 892L: 8, 923L: 2, 927L: 8, 929L: 8, 963L: 8, 965L: 8, 966L: 8, 967L: 8, 983L: 8, 985L: 3, 1027L: 5, 1029L: 8, 1036L: 8, 1039L: 8, 1064L: 7, 1088L: 8, 1089L: 8, 1108L: 8, 1125L: 8, 1296L: 8, 1365L: 5, 1424L: 5, 1600L: 5, 1601L: 8, 1613L: 5, 1616L: 5, 1618L: 5, 1668L: 5, 2015L: 3
+ 57: 3, 145: 8, 228: 5, 229: 4, 308: 5, 316: 8, 339: 7, 342: 6, 344: 8, 380: 8, 392: 6, 399: 7, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 464: 8, 471: 3, 476: 4, 490: 8, 506: 8, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 871: 8, 882: 2, 884: 7, 892: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1088: 8, 1089: 8, 1108: 8, 1125: 8, 1296: 8, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1613: 5, 1616: 5, 1618: 5, 1668: 5, 2015: 3
}]
}
@@ -107,4 +107,5 @@ DBC = {
CAR.RIDGELINE: dbc_dict('honda_ridgeline_black_edition_2017_can_generated', 'acura_ilx_2016_nidec'),
}
+# TODO: get these from dbc file
HONDA_BOSCH = [CAR.ACCORD, CAR.CIVIC_HATCH, CAR.CRV_5G]
diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py
index ffb7907500..db3b8b6a53 100755
--- a/selfdrive/car/mock/interface.py
+++ b/selfdrive/car/mock/interface.py
@@ -3,6 +3,7 @@ import zmq
from cereal import car
from selfdrive.config import Conversions as CV
from selfdrive.services import service_list
+from selfdrive.swaglog import cloudlog
import selfdrive.messaging as messaging
# mocked car interface to work with chffrplus
@@ -17,7 +18,7 @@ class CarInterface(object):
self.CP = CP
- print "Using Mock Car Interface"
+ cloudlog.debug("Using Mock Car Interface")
context = zmq.Context()
# TODO: subscribe to phone sensor
diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py
index d26992ad1f..0170c4c942 100755
--- a/selfdrive/car/toyota/interface.py
+++ b/selfdrive/car/toyota/interface.py
@@ -6,6 +6,7 @@ from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event
from selfdrive.controls.lib.vehicle_model import VehicleModel
from selfdrive.car.toyota.carstate import CarState, get_can_parser
from selfdrive.car.toyota.values import ECU, check_ecu_msgs, CAR
+from selfdrive.swaglog import cloudlog
try:
from selfdrive.car.toyota.carcontroller import CarController
@@ -65,8 +66,8 @@ class CarInterface(object):
centerToFront_civic = wheelbase_civic * 0.4
centerToRear_civic = wheelbase_civic - centerToFront_civic
rotationalInertia_civic = 2500
- tireStiffnessFront_civic = 85400
- tireStiffnessRear_civic = 90000
+ tireStiffnessFront_civic = 192150
+ tireStiffnessRear_civic = 202500
ret.steerKiBP, ret.steerKpBP = [[0.], [0.]]
ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay
@@ -74,39 +75,42 @@ class CarInterface(object):
if candidate == CAR.PRIUS:
ret.safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.70
- ret.steerRatio = 15.0
+ ret.steerRatio = 15.59 # unknown end-to-end spec
+ tire_stiffness_factor = 0.7933
ret.mass = 3045 * CV.LB_TO_KG + std_cargo
ret.steerKpV, ret.steerKiV = [[0.4], [0.01]]
ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
-
- f = 1.43353663
- tireStiffnessFront_civic *= f
- tireStiffnessRear_civic *= f
-
- # Prius has a very bad actuator
+ # TODO: Prius seem to have very laggy actuators. Understand if it is lag or hysteresis
ret.steerActuatorDelay = 0.25
+
elif candidate in [CAR.RAV4, CAR.RAV4H]:
ret.safetyParam = 73 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.65
- ret.steerRatio = 14.5 # Rav4 2017
+ ret.steerRatio = 16.30 # 14.5 is spec end-to-end
+ tire_stiffness_factor = 0.5533
ret.mass = 3650 * CV.LB_TO_KG + std_cargo # mean between normal and hybrid
ret.steerKpV, ret.steerKiV = [[0.6], [0.05]]
ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
+
elif candidate == CAR.COROLLA:
ret.safetyParam = 100 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.70
ret.steerRatio = 17.8
+ tire_stiffness_factor = 0.444
ret.mass = 2860 * CV.LB_TO_KG + std_cargo # mean between normal and hybrid
ret.steerKpV, ret.steerKiV = [[0.2], [0.05]]
ret.steerKf = 0.00003 # full torque for 20 deg at 80mph means 0.00007818594
+
elif candidate == CAR.LEXUS_RXH:
ret.safetyParam = 100 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.79
- ret.steerRatio = 16. # official specs say 14.8, but it does not seem right
+ ret.steerRatio = 16. # 14.8 is spec end-to-end
+ tire_stiffness_factor = 0.444 # not optimized yet
ret.mass = 4481 * CV.LB_TO_KG + std_cargo # mean between min and max
ret.steerKpV, ret.steerKiV = [[0.6], [0.1]]
ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
+ ret.steerRateCost = 1.
ret.centerToFront = ret.wheelbase * 0.44
ret.longPidDeadzoneBP = [0., 9.]
@@ -127,10 +131,10 @@ class CarInterface(object):
# 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.tireStiffnessFront = (tireStiffnessFront_civic * tire_stiffness_factor) * \
ret.mass / mass_civic * \
(centerToRear / ret.wheelbase) / (centerToRear_civic / wheelbase_civic)
- ret.tireStiffnessRear = tireStiffnessRear_civic * \
+ ret.tireStiffnessRear = (tireStiffnessRear_civic * tire_stiffness_factor) * \
ret.mass / mass_civic * \
(ret.centerToFront / ret.wheelbase) / (centerToFront_civic / wheelbase_civic)
@@ -149,9 +153,9 @@ class CarInterface(object):
ret.enableCamera = not check_ecu_msgs(fingerprint, candidate, ECU.CAM)
ret.enableDsu = not check_ecu_msgs(fingerprint, candidate, ECU.DSU)
ret.enableApgs = False #not check_ecu_msgs(fingerprint, candidate, ECU.APGS)
- print "ECU Camera Simulated: ", ret.enableCamera
- print "ECU DSU Simulated: ", ret.enableDsu
- print "ECU APGS Simulated: ", ret.enableApgs
+ cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera)
+ cloudlog.warn("ECU DSU Simulated: %r", ret.enableDsu)
+ cloudlog.warn("ECU APGS Simulated: %r", ret.enableApgs)
ret.steerLimitAlert = False
ret.stoppingControl = False
diff --git a/selfdrive/car/toyota/radar_interface.py b/selfdrive/car/toyota/radar_interface.py
index 1568ff5fa8..9af6aed47b 100755
--- a/selfdrive/car/toyota/radar_interface.py
+++ b/selfdrive/car/toyota/radar_interface.py
@@ -8,7 +8,7 @@ from selfdrive.services import service_list
import selfdrive.messaging as messaging
-RADAR_MSGS = range(0x210, 0x220)
+RADAR_MSGS = list(range(0x210, 0x220))
def _create_radard_can_parser():
dbc_f = 'toyota_prius_2017_adas.dbc'
@@ -90,4 +90,4 @@ if __name__ == "__main__":
while 1:
ret = RI.update()
print(chr(27) + "[2J")
- print ret
+ print(ret)
diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py
index 4749ea247c..649146073f 100644
--- a/selfdrive/car/toyota/values.py
+++ b/selfdrive/car/toyota/values.py
@@ -71,21 +71,21 @@ def check_ecu_msgs(fingerprint, candidate, ecu):
FINGERPRINTS = {
CAR.RAV4: [{
- 36L: 8, 37L: 8, 170L: 8, 180L: 8, 186L: 4, 426L: 6, 452L: 8, 464L: 8, 466L: 8, 467L: 8, 547L: 8, 548L: 8, 552L: 4, 562L: 4, 608L: 8, 610L: 5, 643L: 7, 705L: 8, 725L: 2, 740L: 5, 800L: 8, 835L: 8, 836L: 8, 849L: 4, 869L: 7, 870L: 7, 871L: 2, 896L: 8, 897L: 8, 900L: 6, 902L: 6, 905L: 8, 911L: 8, 916L: 3, 918L: 7, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 951L: 8, 955L: 4, 956L: 8, 979L: 2, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1005L: 2, 1008L: 2, 1014L: 8, 1017L: 8, 1041L: 8, 1042L: 8, 1043L: 8, 1044L: 8, 1056L: 8, 1059L: 1, 1114L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1176L: 8, 1177L: 8, 1178L: 8, 1179L: 8, 1180L: 8, 1181L: 8, 1190L: 8, 1191L: 8, 1192L: 8, 1196L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1263L: 8, 1264L: 8, 1279L: 8, 1408L: 8, 1409L: 8, 1410L: 8, 1552L: 8, 1553L: 8, 1554L: 8, 1555L: 8, 1556L: 8, 1557L: 8, 1561L: 8, 1562L: 8, 1568L: 8, 1569L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1584L: 8, 1589L: 8, 1592L: 8, 1593L: 8, 1595L: 8, 1596L: 8, 1597L: 8, 1600L: 8, 1656L: 8, 1664L: 8, 1728L: 8, 1745L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8
+ 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
}],
CAR.RAV4H: [{
- 36L: 8, 37L: 8, 170L: 8, 180L: 8, 186L: 4, 296L: 8, 426L: 6, 452L: 8, 464L: 8, 466L: 8, 467L: 8, 547L: 8, 548L: 8, 550L: 8, 552L: 4, 560L: 7, 562L: 4, 581L: 5, 608L: 8, 610L: 5, 643L: 7, 705L: 8, 713L: 8, 725L: 2, 740L: 5, 800L: 8, 835L: 8, 836L: 8, 849L: 4, 869L: 7, 870L: 7, 871L: 2, 896L: 8, 897L: 8, 900L: 6, 902L: 6, 905L: 8, 911L: 8, 916L: 3, 918L: 7, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 950L: 8, 951L: 8, 953L: 3, 955L: 8, 956L: 8, 979L: 2, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1005L: 2, 1008L: 2, 1014L: 8, 1017L: 8, 1041L: 8, 1042L: 8, 1043L: 8, 1044L: 8, 1056L: 8, 1059L: 1, 1114L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1176L: 8, 1177L: 8, 1178L: 8, 1179L: 8, 1180L: 8, 1181L: 8, 1184L: 8, 1185L: 8, 1186L: 8, 1190L: 8, 1191L: 8, 1192L: 8, 1196L: 8, 1197L: 8, 1198L: 8, 1199L: 8, 1212L: 8, 1227L: 8, 1228L: 8, 1232L: 8, 1235L: 8, 1237L: 8, 1263L: 8, 1264L: 8, 1279L: 8, 1408L: 8, 1409L: 8, 1410L: 8, 1552L: 8, 1553L: 8, 1554L: 8, 1555L: 8, 1556L: 8, 1557L: 8, 1561L: 8, 1562L: 8, 1568L: 8, 1569L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1584L: 8, 1589L: 8, 1592L: 8, 1593L: 8, 1595L: 8, 1596L: 8, 1597L: 8, 1600L: 8, 1656L: 8, 1664L: 8, 1728L: 8, 1745L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8
+ 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 296: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 550: 8, 552: 4, 560: 7, 562: 4, 581: 5, 608: 8, 610: 5, 643: 7, 705: 8, 713: 8, 725: 2, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1212: 8, 1227: 8, 1228: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
}],
CAR.PRIUS: [{
- 36L: 8, 37L: 8, 166L: 8, 170L: 8, 180L: 8, 295L: 8, 296L: 8, 426L: 6, 452L: 8, 466L: 8, 467L: 8, 550L: 8, 552L: 4, 560L: 7, 562L: 6, 581L: 5, 608L: 8, 610L: 8, 614L: 8, 643L: 7, 658L: 8, 713L: 8, 740L: 5, 742L: 8, 743L: 8, 800L: 8, 810L: 2, 814L: 8, 829L: 2, 830L: 7, 835L: 8, 836L: 8, 863L: 8, 869L: 7, 870L: 7, 871L: 2, 898L: 8, 900L: 6, 902L: 6, 905L: 8, 918L: 8, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 950L: 8, 951L: 8, 953L: 8, 955L: 8, 956L: 8, 971L: 7, 975L: 5, 993L: 8, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1014L: 8, 1017L: 8, 1020L: 8, 1041L: 8, 1042L: 8, 1044L: 8, 1056L: 8, 1057L: 8, 1059L: 1, 1071L: 8, 1077L: 8, 1082L: 8, 1083L: 8, 1084L: 8, 1085L: 8, 1086L: 8, 1114L: 8, 1132L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1175L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1279L: 8, 1552L: 8, 1553L: 8, 1556L: 8, 1557L: 8, 1568L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1595L: 8, 1777L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8
+ 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
},
# Prius Prime
{
- 36L: 8, 37L: 8, 166L: 8, 170L: 8, 180L: 8, 295L: 8, 296L: 8, 426L: 6, 452L: 8, 466L: 8, 467L: 8, 550L: 8, 552L: 4, 560L: 7, 562L: 6, 581L: 5, 608L: 8, 610L: 8, 614L: 8, 643L: 7, 658L: 8, 713L: 8, 740L: 5, 742L: 8, 743L: 8, 800L: 8, 810L: 2, 814L: 8, 824L: 2, 829L: 2, 830L: 7, 835L: 8, 836L: 8, 863L: 8, 869L: 7, 870L: 7, 871L: 2,898L: 8, 900L: 6, 902L: 6, 905L: 8, 913L: 8, 918L: 8, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 950L: 8, 951L: 8, 953L: 8, 955L: 8, 956L: 8, 971L: 7, 974L: 8, 975L: 5, 993L: 8, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1014L: 8, 1017L: 8, 1020L: 8, 1041L: 8, 1042L: 8, 1044L: 8, 1056L: 8, 1057L: 8, 1059L: 1, 1071L: 8, 1076L: 8, 1077L: 8, 1082L: 8, 1083L: 8, 1084L: 8, 1085L: 8, 1086L: 8, 1114L: 8, 1132L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1164L: 8, 1165L: 8, 1166L: 8, 1167L: 8, 1175L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1279L: 8, 1552L: 8, 1553L: 8, 1556L: 8, 1557L: 8, 1568L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1595L: 8, 1777L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8
+ 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 869: 7, 870: 7, 871: 2,898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
},
# Taiwanese Prius Prime
{
- 36L: 8, 37L: 8, 166L: 8, 170L: 8, 180L: 8, 295L: 8, 296L: 8, 426L: 6, 452L: 8, 466L: 8, 467L: 8, 550L: 8, 552L: 4, 560L: 7, 562L: 6, 581L: 5, 608L: 8, 610L: 8, 614L: 8, 643L: 7, 658L: 8, 713L: 8, 740L: 5, 742L: 8, 743L: 8, 800L: 8, 810L: 2, 814L: 8, 824L: 2, 829L: 2, 830L: 7, 835L: 8, 836L: 8, 845L: 5, 863L: 8, 869L: 7, 870L: 7, 871L: 2,898L: 8, 900L: 6, 902L: 6, 905L: 8, 913L: 8, 918L: 8, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 950L: 8, 951L: 8, 953L: 8, 955L: 8, 956L: 8, 971L: 7, 974L: 8, 975L: 5, 993L: 8, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1005L: 2, 1014L: 8, 1017L: 8, 1020L: 8, 1041L: 8, 1042L: 8, 1044L: 8, 1056L: 8, 1057L: 8, 1059L: 1, 1071L: 8, 1076L: 8, 1077L: 8, 1082L: 8, 1083L: 8, 1084L: 8, 1085L: 8, 1086L: 8, 1114L: 8, 1132L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1164L: 8, 1165L: 8, 1166L: 8, 1167L: 8, 1175L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1264L: 8, 1279L: 8, 1552L: 8, 1553L: 8, 1556L: 8, 1557L: 8, 1568L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1595L: 8, 1777L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8
+ 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2,898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
}],
CAR.COROLLA: [{
36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 2, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1196: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
diff --git a/selfdrive/common/touch.c b/selfdrive/common/touch.c
index 2367d8d98c..eb59db965f 100644
--- a/selfdrive/common/touch.c
+++ b/selfdrive/common/touch.c
@@ -48,7 +48,7 @@ void touch_init(TouchState *s) {
assert(s->fd >= 0);
}
-int touch_poll(TouchState *s, int* out_x, int* out_y) {
+int touch_poll(TouchState *s, int* out_x, int* out_y, int timeout) {
assert(out_x && out_y);
bool up = false;
while (true) {
@@ -56,7 +56,7 @@ int touch_poll(TouchState *s, int* out_x, int* out_y) {
.fd = s->fd,
.events = POLLIN,
}};
- int err = poll(polls, 1, 0);
+ int err = poll(polls, 1, timeout);
if (err < 0) {
return -1;
}
diff --git a/selfdrive/common/touch.h b/selfdrive/common/touch.h
index 3767c06dc3..c2bb6dfece 100644
--- a/selfdrive/common/touch.h
+++ b/selfdrive/common/touch.h
@@ -11,7 +11,7 @@ typedef struct TouchState {
} TouchState;
void touch_init(TouchState *s);
-int touch_poll(TouchState *s, int *out_x, int *out_y);
+int touch_poll(TouchState *s, int *out_x, int *out_y, int timeout);
#ifdef __cplusplus
}
diff --git a/selfdrive/common/util.c b/selfdrive/common/util.c
index 172345869e..6f8f0a9a6c 100644
--- a/selfdrive/common/util.c
+++ b/selfdrive/common/util.c
@@ -2,9 +2,12 @@
#include
#include
#include
+#include
#ifdef __linux__
#include
+#include
+#include
#endif
void* read_file(const char* path, size_t* out_len) {
@@ -39,3 +42,17 @@ void set_thread_name(const char* name) {
prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0);
#endif
}
+
+int set_realtime_priority(int level) {
+#ifdef __linux__
+
+ long tid = syscall(SYS_gettid);
+
+ // should match python using chrt
+ struct sched_param sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sched_priority = level;
+ return sched_setscheduler(tid, SCHED_FIFO, &sa);
+#endif
+}
+
diff --git a/selfdrive/common/util.h b/selfdrive/common/util.h
index ce18068bbe..65dde16e24 100644
--- a/selfdrive/common/util.h
+++ b/selfdrive/common/util.h
@@ -24,6 +24,8 @@
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
+#define ALIGN(x, align) (((x) + (align)-1) & ~((align)-1))
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -36,6 +38,8 @@ void* read_file(const char* path, size_t* out_len);
void set_thread_name(const char* name);
+int set_realtime_priority(int level);
+
#ifdef __cplusplus
}
#endif
diff --git a/selfdrive/common/version.h b/selfdrive/common/version.h
index 8fcd679d60..2b226fc6e0 100644
--- a/selfdrive/common/version.h
+++ b/selfdrive/common/version.h
@@ -1 +1 @@
-#define COMMA_VERSION "0.4.7.2-release"
+#define COMMA_VERSION "0.5-release"
diff --git a/selfdrive/common/visionbuf.h b/selfdrive/common/visionbuf.h
new file mode 100644
index 0000000000..3457f6dff3
--- /dev/null
+++ b/selfdrive/common/visionbuf.h
@@ -0,0 +1,39 @@
+#ifndef IONBUF_H
+#define IONBUF_H
+
+#ifdef __APPLE__
+#include
+#else
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct VisionBuf {
+ size_t len;
+ void* addr;
+ int handle;
+ int fd;
+
+ cl_context ctx;
+ cl_device_id device_id;
+ cl_mem buf_cl;
+ cl_command_queue copy_q;
+} VisionBuf;
+
+#define VISIONBUF_SYNC_FROM_DEVICE 0
+#define VISIONBUF_SYNC_TO_DEVICE 1
+
+VisionBuf visionbuf_allocate(size_t len);
+VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem);
+cl_mem visionbuf_to_cl(const VisionBuf* buf, cl_device_id device_id, cl_context ctx);
+void visionbuf_sync(const VisionBuf* buf, int dir);
+void visionbuf_free(const VisionBuf* buf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/selfdrive/common/visionbuf_ion.c b/selfdrive/common/visionbuf_ion.c
new file mode 100644
index 0000000000..724e75e9b0
--- /dev/null
+++ b/selfdrive/common/visionbuf_ion.c
@@ -0,0 +1,141 @@
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+#include "visionbuf.h"
+
+
+// just hard-code these for convenience
+// size_t device_page_size = 0;
+// clGetDeviceInfo(device_id, CL_DEVICE_PAGE_SIZE_QCOM,
+// sizeof(device_page_size), &device_page_size,
+// NULL);
+
+// size_t padding_cl = 0;
+// clGetDeviceInfo(device_id, CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM,
+// sizeof(padding_cl), &padding_cl,
+// NULL);
+#define DEVICE_PAGE_SIZE_CL 4096
+#define PADDING_CL 0
+
+static int ion_fd = -1;
+static void ion_init() {
+ if (ion_fd == -1) {
+ ion_fd = open("/dev/ion", O_RDWR | O_NONBLOCK);
+ }
+}
+
+VisionBuf visionbuf_allocate(size_t len) {
+ int err;
+
+ ion_init();
+
+ struct ion_allocation_data ion_alloc = {0};
+ ion_alloc.len = len + PADDING_CL;
+ ion_alloc.align = 4096;
+ ion_alloc.heap_id_mask = 1 << ION_IOMMU_HEAP_ID;
+ ion_alloc.flags = ION_FLAG_CACHED;
+
+ err = ioctl(ion_fd, ION_IOC_ALLOC, &ion_alloc);
+ assert(err == 0);
+
+ struct ion_fd_data ion_fd_data = {0};
+ ion_fd_data.handle = ion_alloc.handle;
+ err = ioctl(ion_fd, ION_IOC_SHARE, &ion_fd_data);
+ assert(err == 0);
+
+ void *addr = mmap(NULL, ion_alloc.len,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, ion_fd_data.fd, 0);
+ assert(addr != MAP_FAILED);
+
+ memset(addr, 0, ion_alloc.len);
+
+ return (VisionBuf){
+ .len = len,
+ .addr = addr,
+ .handle = ion_alloc.handle,
+ .fd = ion_fd_data.fd,
+ };
+}
+
+VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem) {
+ VisionBuf r = visionbuf_allocate(len);
+ *out_mem = visionbuf_to_cl(&r, device_id, ctx);
+ return r;
+}
+
+cl_mem visionbuf_to_cl(const VisionBuf* buf, cl_device_id device_id, cl_context ctx) {
+ int err = 0;
+
+ assert(((uintptr_t)buf->addr % DEVICE_PAGE_SIZE_CL) == 0);
+
+ cl_mem_ion_host_ptr ion_cl = {0};
+ ion_cl.ext_host_ptr.allocation_type = CL_MEM_ION_HOST_PTR_QCOM;
+ ion_cl.ext_host_ptr.host_cache_policy = CL_MEM_HOST_UNCACHED_QCOM;
+ ion_cl.ion_filedesc = buf->fd;
+ ion_cl.ion_hostptr = buf->addr;
+
+ cl_mem mem = clCreateBuffer(ctx,
+ CL_MEM_USE_HOST_PTR | CL_MEM_EXT_HOST_PTR_QCOM,
+ buf->len, &ion_cl, &err);
+ assert(err == 0);
+
+ return mem;
+}
+
+void visionbuf_sync(const VisionBuf* buf, int dir) {
+ int err;
+
+ struct ion_fd_data fd_data = {0};
+ fd_data.fd = buf->fd;
+ err = ioctl(ion_fd, ION_IOC_IMPORT, &fd_data);
+ assert(err == 0);
+
+ struct ion_flush_data flush_data = {0};
+ flush_data.handle = fd_data.handle;
+ flush_data.vaddr = buf->addr;
+ flush_data.offset = 0;
+ flush_data.length = buf->len;
+
+ // ION_IOC_INV_CACHES ~= DMA_FROM_DEVICE
+ // ION_IOC_CLEAN_CACHES ~= DMA_TO_DEVICE
+ // ION_IOC_CLEAN_INV_CACHES ~= DMA_BIDIRECTIONAL
+
+ struct ion_custom_data custom_data = {0};
+
+ switch (dir) {
+ case VISIONBUF_SYNC_FROM_DEVICE:
+ custom_data.cmd = ION_IOC_INV_CACHES;
+ break;
+ case VISIONBUF_SYNC_TO_DEVICE:
+ custom_data.cmd = ION_IOC_CLEAN_CACHES;
+ break;
+ default:
+ assert(0);
+ }
+
+ custom_data.arg = (unsigned long)&flush_data;
+ err = ioctl(ion_fd, ION_IOC_CUSTOM, &custom_data);
+ assert(err == 0);
+
+ struct ion_handle_data handle_data = {0};
+ handle_data.handle = fd_data.handle;
+ err = ioctl(ion_fd, ION_IOC_FREE, &handle_data);
+ assert(err == 0);
+}
+
+void visionbuf_free(const VisionBuf* buf) {
+ struct ion_handle_data handle_data = {
+ .handle = buf->handle,
+ };
+ int ret = ioctl(ion_fd, ION_IOC_FREE, &handle_data);
+ assert(ret == 0);
+}
diff --git a/selfdrive/common/visionimg.cc b/selfdrive/common/visionimg.cc
new file mode 100644
index 0000000000..45bc7bfc4a
--- /dev/null
+++ b/selfdrive/common/visionimg.cc
@@ -0,0 +1,111 @@
+#include
+
+#ifdef QCOM
+#include
+#include
+#include
+#include
+
+#include
+#define GL_GLEXT_PROTOTYPES
+#include
+
+#include
+#define EGL_EGLEXT_PROTOTYPES
+#include
+
+#endif
+
+#include "common/util.h"
+#include "common/visionbuf.h"
+
+#include "common/visionimg.h"
+
+#ifdef QCOM
+
+using namespace android;
+
+// 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);
+#endif
+
+VisionImg visionimg_alloc_rgb24(int width, int height, VisionBuf *out_buf) {
+
+ 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;
+
+ VisionBuf buf = visionbuf_allocate(size);
+
+ *out_buf = buf;
+
+ return (VisionImg){
+ .fd = buf.fd,
+ .format = VISIONIMG_FORMAT_RGB24,
+ .width = width,
+ .height = height,
+ .stride = stride,
+ .size = size,
+ .bpp = 3,
+ };
+}
+
+#ifdef QCOM
+
+EGLClientBuffer visionimg_to_egl(const VisionImg *img) {
+ assert((img->size % img->stride) == 0);
+ assert((img->stride % img->bpp) == 0);
+
+ int format = 0;
+ if (img->format == VISIONIMG_FORMAT_RGB24) {
+ format = HAL_PIXEL_FORMAT_RGB_888;
+ } else {
+ assert(false);
+ }
+
+ private_handle_t* hnd = new private_handle_t(img->fd, img->size,
+ private_handle_t::PRIV_FLAGS_USES_ION|private_handle_t::PRIV_FLAGS_FRAMEBUFFER,
+ 0, format,
+ img->stride/img->bpp, img->size/img->stride,
+ img->width, img->height);
+
+ GraphicBuffer* gb = new GraphicBuffer(img->width, img->height, (PixelFormat)format,
+ GraphicBuffer::USAGE_HW_TEXTURE, img->stride/img->bpp, hnd, false);
+
+ return (EGLClientBuffer) gb->getNativeBuffer();
+}
+
+GLuint visionimg_to_gl(const VisionImg *img) {
+
+ EGLClientBuffer buf = visionimg_to_egl(img);
+
+ EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ assert(display != EGL_NO_DISPLAY);
+
+ EGLint img_attrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };
+ EGLImageKHR image = eglCreateImageKHR(display, EGL_NO_CONTEXT,
+ EGL_NATIVE_BUFFER_ANDROID, buf, img_attrs);
+ assert(image != EGL_NO_IMAGE_KHR);
+
+ GLuint tex = 0;
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+
+ return tex;
+}
+
+#endif
diff --git a/selfdrive/common/visionimg.h b/selfdrive/common/visionimg.h
new file mode 100644
index 0000000000..1a98b55bc7
--- /dev/null
+++ b/selfdrive/common/visionimg.h
@@ -0,0 +1,37 @@
+#ifndef VISIONIMG_H
+#define VISIONIMG_H
+
+#ifdef QCOM
+#include
+#include
+#include
+#endif
+
+#include "common/visionbuf.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define VISIONIMG_FORMAT_RGB24 1
+
+typedef struct VisionImg {
+ int fd;
+ int format;
+ int width, height, stride;
+ int bpp;
+ size_t size;
+} VisionImg;
+
+VisionImg visionimg_alloc_rgb24(int width, int height, VisionBuf *out_buf);
+
+#ifdef QCOM
+EGLClientBuffer visionimg_to_egl(const VisionImg *img);
+GLuint visionimg_to_gl(const VisionImg *img);
+#endif
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
diff --git a/selfdrive/common/visionipc.h b/selfdrive/common/visionipc.h
index 8bd0dd152f..4844a71b1d 100644
--- a/selfdrive/common/visionipc.h
+++ b/selfdrive/common/visionipc.h
@@ -21,8 +21,8 @@ typedef enum VisionIPCPacketType {
} VisionIPCPacketType;
typedef enum VisionStreamType {
- VISION_STREAM_UI_BACK,
- VISION_STREAM_UI_FRONT,
+ VISION_STREAM_RGB_BACK,
+ VISION_STREAM_RGB_FRONT,
VISION_STREAM_YUV,
VISION_STREAM_YUV_FRONT,
VISION_STREAM_MAX,
diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py
index bcad96b02c..1b8ad21282 100755
--- a/selfdrive/controls/controlsd.py
+++ b/selfdrive/controls/controlsd.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
+import gc
import json
-from copy import copy
import zmq
from cereal import car, log
from common.numpy_fast import clip
@@ -17,18 +17,18 @@ from selfdrive.controls.lib.drive_helpers import learn_angle_offset, \
create_event, \
EventTypes as ET, \
update_v_cruise, \
- initialize_v_cruise
+ initialize_v_cruise, \
+ kill_defaultd
from selfdrive.controls.lib.longcontrol import LongControl, STARTING_TARGET_SPEED
from selfdrive.controls.lib.latcontrol import LatControl
from selfdrive.controls.lib.alertmanager import AlertManager
from selfdrive.controls.lib.vehicle_model import VehicleModel
+from selfdrive.controls.lib.driver_monitor import DriverStatus
-
-AWARENESS_TIME = 360. # 6 minutes limit without user touching steering wheels
-AWARENESS_PRE_TIME = 20. # a first alert is issued 20s before start decelerating the car
-
+ThermalStatus = log.ThermalData.ThermalStatus
State = log.Live100Data.ControlState
+
class Calibration:
UNCALIBRATED = 0
CALIBRATED = 1
@@ -45,15 +45,20 @@ def isEnabled(state):
return (isActive(state) or state == State.preEnabled)
-def data_sample(CI, CC, thermal, calibration, health, poller, cal_status, overtemp, free_space):
+def data_sample(CI, CC, thermal, calibration, health, driver_monitor, gps_location,
+ poller, cal_status, overtemp, free_space, driver_status, geofence,
+ state, mismatch_counter, params):
# *** read can and compute car states ***
CS = CI.update(CC)
events = list(CS.events)
+ enabled = isEnabled(state)
td = None
cal = None
hh = None
+ dm = None
+ gps = None
for socket, event in poller.poll(0):
if socket is thermal:
@@ -62,16 +67,15 @@ def data_sample(CI, CC, thermal, calibration, health, poller, cal_status, overte
cal = messaging.recv_one(socket)
elif socket is health:
hh = messaging.recv_one(socket)
+ elif socket is driver_monitor:
+ dm = messaging.recv_one(socket)
+ elif socket is gps_location:
+ gps = messaging.recv_one(socket)
# *** thermal checking logic ***
# thermal data, checked every second
if td is not None:
- # CPU overtemp above 95 deg
- overtemp_proc = any(t > 950 for t in
- (td.thermal.cpu0, td.thermal.cpu1, td.thermal.cpu2,
- td.thermal.cpu3, td.thermal.mem, td.thermal.gpu))
- overtemp_bat = td.thermal.bat > 60000 # 60c
- overtemp = overtemp_proc or overtemp_bat
+ overtemp = td.thermal.thermalStatus >= ThermalStatus.red
# under 15% of space free no enable allowed
free_space = td.thermal.freeSpace < 0.15
@@ -92,18 +96,34 @@ def data_sample(CI, CC, thermal, calibration, health, poller, cal_status, overte
else:
events.append(create_event('calibrationInvalid', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
+ if not enabled:
+ mismatch_counter = 0
+
# *** health checking logic ***
if hh is not None:
controls_allowed = hh.health.controlsAllowed
- if not controls_allowed:
+ if not controls_allowed and enabled:
+ mismatch_counter += 1
+
+ if mismatch_counter >= 2:
events.append(create_event('controlsMismatch', [ET.IMMEDIATE_DISABLE]))
- return CS, events, cal_status, overtemp, free_space
+ if dm is not None:
+ driver_status.get_pose(dm.driverMonitoring, params)
+ if geofence is not None and gps is not None:
+ geofence.update_geofence_status(gps.gpsLocationExternal, params)
-def calc_plan(CS, CP, events, PL, LaC, LoC, v_cruise_kph, awareness_status):
+ if geofence is not None and not geofence.in_geofence:
+ events.append(create_event('geofence', [ET.NO_ENTRY, ET.WARNING]))
+
+ return CS, events, cal_status, overtemp, free_space, mismatch_counter
+
+
+def calc_plan(CS, CP, events, PL, LaC, LoC, v_cruise_kph, driver_status, geofence):
# plan runs always, independently of the state
- plan_packet = PL.update(CS, LaC, LoC, v_cruise_kph, awareness_status < -0.)
+ force_decel = driver_status.awareness < 0. or (geofence is not None and not geofence.in_geofence)
+ plan_packet = PL.update(CS, LaC, LoC, v_cruise_kph, force_decel)
plan = plan_packet.plan
plan_ts = plan_packet.logMonoTime
@@ -127,6 +147,8 @@ def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM
# if stock cruise is completely disabled, then we can use our own set speed logic
if not CP.enableCruise:
v_cruise_kph = update_v_cruise(v_cruise_kph, CS.buttonEvents, enabled)
+ elif CP.enableCruise and CS.cruiseState.enabled:
+ v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH
# decrease the soft disable timer at every step, as it's reset on
# entrance in SOFT_DISABLING state
@@ -147,7 +169,7 @@ def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM
else:
state = State.enabled
AM.add("enable", enabled)
- v_cruise_kph = initialize_v_cruise(CS.vEgo)
+ v_cruise_kph = initialize_v_cruise(CS.vEgo, CS.buttonEvents, v_cruise_kph_last)
# ENABLED
elif state == State.enabled:
@@ -202,8 +224,7 @@ def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM
def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, AM, rk,
- awareness_status, PL, LaC, LoC, VM, angle_offset, rear_view_allowed,
- rear_view_toggle, passive):
+ driver_status, PL, LaC, LoC, VM, angle_offset, passive):
# Given the state, this function returns the actuators
# reset actuators to zero
@@ -212,14 +233,13 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
enabled = isEnabled(state)
active = isActive(state)
- for b in CS.buttonEvents:
- # button presses for rear view
- if b.type == "leftBlinker" or b.type == "rightBlinker":
- rear_view_toggle = b.pressed and rear_view_allowed
-
- if (b.type == "altButton1" and b.pressed) and not passive:
- rear_view_toggle = not rear_view_toggle
+ # check if user has interacted with the car
+ driver_engaged = len(CS.buttonEvents) > 0 or \
+ v_cruise_kph != v_cruise_kph_last or \
+ CS.steeringPressed
+ # add eventual driver distracted events
+ events = driver_status.update(events, driver_engaged, isActive(state), CS.standstill)
# send FCW alert if triggered by planner
if plan.fcw:
@@ -236,14 +256,6 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
# ENABLED or SOFT_DISABLING
elif state in [State.enabled, State.softDisabling]:
- # decrease awareness status
- awareness_status -= 0.01/(AWARENESS_TIME)
- if awareness_status <= 0.:
- AM.add("driverDistracted", enabled)
- elif awareness_status <= AWARENESS_PRE_TIME / AWARENESS_TIME and \
- awareness_status >= (AWARENESS_PRE_TIME - 4.) / AWARENESS_TIME:
- AM.add("preDriverDistracted", enabled)
-
# parse warnings from car specific interface
for e in get_events(events, [ET.WARNING]):
AM.add(e, enabled)
@@ -265,16 +277,6 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
actuators.steer, actuators.steerAngle = LaC.update(active, CS.vEgo, CS.steeringAngle,
CS.steeringPressed, plan.dPoly, angle_offset, VM, PL)
- if CP.enableCruise and CS.cruiseState.enabled:
- v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH
-
- # reset conditions for the 6 minutes timout
- if CS.buttonEvents or \
- v_cruise_kph != v_cruise_kph_last or \
- CS.steeringPressed or \
- state in [State.preEnabled, State.disabled]:
- awareness_status = 1.
-
# send a "steering required alert" if saturation count has reached the limit
if LaC.sat_flag and CP.steerLimitAlert:
AM.add("steerSaturated", enabled)
@@ -287,11 +289,11 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
AM.process_alerts(sec_since_boot())
- return actuators, v_cruise_kph, awareness_status, angle_offset, rear_view_toggle
+ return actuators, v_cruise_kph, driver_status, angle_offset
def data_send(plan, plan_ts, CS, CI, CP, VM, state, events, actuators, v_cruise_kph, rk, carstate,
- carcontrol, live100, livempc, AM, rear_view_allowed, rear_view_toggle, awareness_status,
+ carcontrol, live100, livempc, AM, driver_status,
LaC, LoC, angle_offset, passive):
# ***** control the car *****
@@ -328,74 +330,54 @@ def data_send(plan, plan_ts, CS, CI, CP, VM, state, events, actuators, v_cruise_
dat = messaging.new_message()
dat.init('live100')
- # show rear view camera on phone if in reverse gear or when button is pressed
- dat.live100.rearViewCam = ('reverseGear' in [e.name for e in events] and rear_view_allowed) or rear_view_toggle
- dat.live100.alertText1 = AM.alert_text_1
- dat.live100.alertText2 = AM.alert_text_2
- dat.live100.alertSize = AM.alert_size
- dat.live100.alertStatus = AM.alert_status
- dat.live100.awarenessStatus = max(awareness_status, 0.0) if isEnabled(state) else 0.0
-
- # what packets were used to process
- dat.live100.canMonoTimes = list(CS.canMonoTimes)
- dat.live100.planMonoTime = plan_ts
-
- # if controls is enabled
- dat.live100.enabled = isEnabled(state)
- dat.live100.active = isActive(state)
-
- # car state
- dat.live100.vEgo = CS.vEgo
- dat.live100.vEgoRaw = CS.vEgoRaw
- dat.live100.angleSteers = CS.steeringAngle
- dat.live100.curvature = VM.calc_curvature(CS.steeringAngle * CV.DEG_TO_RAD, CS.vEgo)
- dat.live100.steerOverride = CS.steeringPressed
-
- # high level control state
- dat.live100.state = state
-
- # longitudinal control state
- dat.live100.longControlState = LoC.long_control_state
- dat.live100.vPid = float(LoC.v_pid)
- dat.live100.vCruise = float(v_cruise_kph)
- dat.live100.upAccelCmd = float(LoC.pid.p)
- dat.live100.uiAccelCmd = float(LoC.pid.i)
- dat.live100.ufAccelCmd = float(LoC.pid.f)
-
- # lateral control state
- dat.live100.angleSteersDes = float(LaC.angle_steers_des)
- dat.live100.upSteer = float(LaC.pid.p)
- dat.live100.uiSteer = float(LaC.pid.i)
- dat.live100.ufSteer = float(LaC.pid.f)
-
- # processed radar state, should add a_pcm?
- dat.live100.vTargetLead = float(plan.vTarget)
- dat.live100.aTarget = float(plan.aTarget)
- dat.live100.jerkFactor = float(plan.jerkFactor)
-
- # log learned angle offset
- dat.live100.angleOffset = float(angle_offset)
-
- # Save GPS planner status
- dat.live100.gpsPlannerActive = plan.gpsPlannerActive
-
- # lag
- dat.live100.cumLagMs = -rk.remaining*1000.
-
+ dat.live100 = {
+ "alertText1": AM.alert_text_1,
+ "alertText2": AM.alert_text_2,
+ "alertSize": AM.alert_size,
+ "alertStatus": AM.alert_status,
+ "alertBlinkingRate": AM.alert_rate,
+ "awarenessStatus": max(driver_status.awareness, 0.0) if isEnabled(state) else 0.0,
+ "canMonoTimes": list(CS.canMonoTimes),
+ "planMonoTime": plan_ts,
+ "enabled": isEnabled(state),
+ "active": isActive(state),
+ "vEgo": CS.vEgo,
+ "vEgoRaw": CS.vEgoRaw,
+ "angleSteers": CS.steeringAngle,
+ "curvature": VM.calc_curvature(CS.steeringAngle * CV.DEG_TO_RAD, CS.vEgo),
+ "steerOverride": CS.steeringPressed,
+ "state": state,
+ "engageable": not bool(get_events(events, [ET.NO_ENTRY])),
+ "longControlState": LoC.long_control_state,
+ "vPid": float(LoC.v_pid),
+ "vCruise": float(v_cruise_kph),
+ "upAccelCmd": float(LoC.pid.p),
+ "uiAccelCmd": float(LoC.pid.i),
+ "ufAccelCmd": float(LoC.pid.f),
+ "angleSteersDes": float(LaC.angle_steers_des),
+ "upSteer": float(LaC.pid.p),
+ "uiSteer": float(LaC.pid.i),
+ "ufSteer": float(LaC.pid.f),
+ "vTargetLead": float(plan.vTarget),
+ "aTarget": float(plan.aTarget),
+ "jerkFactor": float(plan.jerkFactor),
+ "angleOffset": float(angle_offset),
+ "gpsPlannerActive": plan.gpsPlannerActive,
+ "cumLagMs": -rk.remaining*1000.,
+ }
live100.send(dat.to_bytes())
# broadcast carState
cs_send = messaging.new_message()
cs_send.init('carState')
- # TODO: override CS.events with all the cumulated events
- cs_send.carState = copy(CS)
+ cs_send.carState = CS
cs_send.carState.events = events
carstate.send(cs_send.to_bytes())
# broadcast carControl
cc_send = messaging.new_message()
cc_send.init('carControl')
- cc_send.carControl = copy(CC)
+ cc_send.carControl = CC
carcontrol.send(cc_send.to_bytes())
# publish mpc state at 20Hz
@@ -413,11 +395,12 @@ def data_send(plan, plan_ts, CS, CI, CP, VM, state, events, actuators, v_cruise_
def controlsd_thread(gctx=None, rate=100, default_bias=0.):
+ gc.disable()
+
# start the loop
set_realtime_priority(3)
context = zmq.Context()
-
params = Params()
# pub
@@ -428,7 +411,12 @@ def controlsd_thread(gctx=None, rate=100, default_bias=0.):
passive = params.get("Passive") != "0"
if not passive:
- sendcan = messaging.pub_sock(context, service_list['sendcan'].port)
+ while 1:
+ try:
+ sendcan = messaging.pub_sock(context, service_list['sendcan'].port)
+ break
+ except zmq.error.ZMQError:
+ kill_defaultd()
else:
sendcan = None
@@ -437,6 +425,8 @@ def controlsd_thread(gctx=None, rate=100, default_bias=0.):
thermal = messaging.sub_sock(context, service_list['thermal'].port, conflate=True, poller=poller)
health = messaging.sub_sock(context, service_list['health'].port, conflate=True, poller=poller)
cal = messaging.sub_sock(context, service_list['liveCalibration'].port, conflate=True, poller=poller)
+ driver_monitor = messaging.sub_sock(context, service_list['driverMonitoring'].port, conflate=True, poller=poller)
+ gps_location = messaging.sub_sock(context, service_list['gpsLocationExternal'].port, conflate=True, poller=poller)
logcan = messaging.sub_sock(context, service_list['can'].port)
@@ -456,12 +446,21 @@ def controlsd_thread(gctx=None, rate=100, default_bias=0.):
CP.safetyModel = car.CarParams.SafetyModels.noOutput
fcw_enabled = params.get("IsFcwEnabled") == "1"
+ driver_monitor_on = params.get("IsDriverMonitoringEnabled") == "1"
+ geofence = None
+ try:
+ from selfdrive.controls.lib.geofence import Geofence
+ geofence = Geofence(params.get("IsGeofenceEnabled") == "1")
+ except ImportError:
+ # geofence not available
+ params.put("IsGeofenceEnabled", "-1")
PL = Planner(CP, fcw_enabled)
LoC = LongControl(CP, CI.compute_gb)
VM = VehicleModel(CP)
LaC = LatControl(VM)
AM = AlertManager()
+ driver_status = DriverStatus(driver_monitor_on)
if not passive:
AM.add("startup", False)
@@ -472,15 +471,11 @@ def controlsd_thread(gctx=None, rate=100, default_bias=0.):
state = State.disabled
soft_disable_timer = 0
v_cruise_kph = 255
+ v_cruise_kph_last = 0
overtemp = False
free_space = False
cal_status = Calibration.UNCALIBRATED
- rear_view_toggle = False
- rear_view_allowed = params.get("IsRearViewMirror") == "1"
-
- # 0.0 - 1.0
- awareness_status = 1.
- v_cruise_kph_last = 0
+ mismatch_counter = 0
rk = Ratekeeper(rate, print_delay_threshold=2./1000)
@@ -501,30 +496,28 @@ def controlsd_thread(gctx=None, rate=100, default_bias=0.):
prof.checkpoint("Ratekeeper", ignore=True)
# sample data and compute car events
- CS, events, cal_status, overtemp, free_space = data_sample(CI, CC, thermal, cal, health, poller, cal_status,
- overtemp, free_space)
+ CS, events, cal_status, overtemp, free_space, mismatch_counter = data_sample(CI, CC, thermal, cal, health,
+ driver_monitor, gps_location, poller, cal_status, overtemp, free_space, driver_status, geofence, state, mismatch_counter, params)
prof.checkpoint("Sample")
# define plan
- plan, plan_ts = calc_plan(CS, CP, events, PL, LaC, LoC, v_cruise_kph, awareness_status)
+ plan, plan_ts = calc_plan(CS, CP, events, PL, LaC, LoC, v_cruise_kph, driver_status, geofence)
prof.checkpoint("Plan")
if not passive:
# update control state
- state, soft_disable_timer, v_cruise_kph, v_cruise_kph_last = state_transition(CS, CP, state, events, soft_disable_timer,
- v_cruise_kph, AM)
+ state, soft_disable_timer, v_cruise_kph, v_cruise_kph_last = \
+ state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM)
prof.checkpoint("State transition")
# compute actuators
- actuators, v_cruise_kph, awareness_status, angle_offset, rear_view_toggle = state_control(plan, CS, CP, state, events, v_cruise_kph,
- v_cruise_kph_last, AM, rk, awareness_status, PL, LaC, LoC, VM,
- angle_offset, rear_view_allowed, rear_view_toggle, passive)
+ actuators, v_cruise_kph, driver_status, angle_offset = state_control(plan, CS, CP, state, events, v_cruise_kph,
+ v_cruise_kph_last, AM, rk, driver_status, PL, LaC, LoC, VM, angle_offset, passive)
prof.checkpoint("State Control")
# publish data
- CC = data_send(plan, plan_ts, CS, CI, CP, VM, state, events, actuators, v_cruise_kph,
- rk, carstate, carcontrol, live100, livempc, AM, rear_view_allowed,
- rear_view_toggle, awareness_status, LaC, LoC, angle_offset, passive)
+ CC = data_send(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)
prof.checkpoint("Sent")
# *** run loop at fixed rate ***
diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py
index 319e717cd4..9d053c211f 100644
--- a/selfdrive/controls/lib/alertmanager.py
+++ b/selfdrive/controls/lib/alertmanager.py
@@ -6,6 +6,7 @@ import copy
# Priority
class Priority:
+ HIGHEST = 4
HIGH = 3
MID = 2
LOW = 1
@@ -25,7 +26,8 @@ class Alert(object):
audible_alert,
duration_sound,
duration_hud_alert,
- duration_text):
+ duration_text,
+ alert_rate=0.):
self.alert_text_1 = alert_text_1
self.alert_text_2 = alert_text_2
@@ -40,6 +42,7 @@ class Alert(object):
self.duration_text = duration_text
self.start_time = 0.
+ self.alert_rate = alert_rate
# typecheck that enums are valid on startup
tst = car.CarControl.new_message()
@@ -74,7 +77,7 @@ class AlertManager(object):
"Brake!",
"Risk of Collision",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "fcw", "chimeRepeated", 1., 2., 2.),
+ Priority.HIGHEST, "fcw", "chimeRepeated", 1., 2., 2.),
"steerSaturated": Alert(
"TAKE CONTROL",
@@ -95,16 +98,28 @@ class AlertManager(object):
Priority.LOW, None, None, .2, .2, .2),
"preDriverDistracted": Alert(
+ "TAKE CONTROL: User Appears Distracted",
+ "",
+ AlertStatus.normal, AlertSize.small,
+ Priority.LOW, "steerRequired", None, 0., .1, .1, alert_rate=0.75),
+
+ "promptDriverDistracted": Alert(
"TAKE CONTROL",
"User Appears Distracted",
AlertStatus.userPrompt, AlertSize.mid,
- Priority.LOW, "steerRequired", None, 0., .1, .1),
+ Priority.MID, "steerRequired", "chimeRepeated", .1, .1, .1),
"driverDistracted": Alert(
- "TAKE CONTROL TO REGAIN SPEED",
- "User Appears Distracted",
+ "DISENGAGEMENT REQUIRED",
+ "User Was Distracted",
AlertStatus.critical, AlertSize.full,
- Priority.MID, "steerRequired", "chimeRepeated", .1, .1, .1),
+ Priority.HIGH, "steerRequired", "chimeRepeated", .1, .1, .1),
+
+ "geofence": Alert(
+ "DISENGAGEMENT REQUIRED",
+ "Not in Geofenced Area",
+ AlertStatus.userPrompt, AlertSize.mid,
+ Priority.HIGH, "steerRequired", "chimeRepeated", .1, .1, .1),
"startup": Alert(
"Be ready to take over at any time",
@@ -116,7 +131,7 @@ class AlertManager(object):
"TAKE CONTROL IMMEDIATELY",
"Ethical Dilemma Detected",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 3.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 3.),
"steerTempUnavailableNoEntry": Alert(
"openpilot Unavailable",
@@ -239,73 +254,73 @@ class AlertManager(object):
"TAKE CONTROL IMMEDIATELY",
"Radar Error: Restart the Car",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"radarFault": Alert(
"TAKE CONTROL IMMEDIATELY",
"Radar Error: Restart the Car",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"modelCommIssue": Alert(
"TAKE CONTROL IMMEDIATELY",
"Model Error: Check Internet Connection",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"controlsFailed": Alert(
"TAKE CONTROL IMMEDIATELY",
"Controls Failed",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"controlsMismatch": Alert(
"TAKE CONTROL IMMEDIATELY",
"Controls Mismatch",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"commIssue": Alert(
"TAKE CONTROL IMMEDIATELY",
"CAN Error: Check Connections",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"steerUnavailable": Alert(
"TAKE CONTROL IMMEDIATELY",
"Steer Fault: Restart the Car",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"brakeUnavailable": Alert(
"TAKE CONTROL IMMEDIATELY",
"Brake Fault: Restart the Car",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"gasUnavailable": Alert(
"TAKE CONTROL IMMEDIATELY",
"Gas Fault: Restart the Car",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"reverseGear": Alert(
"TAKE CONTROL IMMEDIATELY",
"Reverse Gear",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"cruiseDisabled": Alert(
"TAKE CONTROL IMMEDIATELY",
"Cruise Is Off",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
"plannerError": Alert(
"TAKE CONTROL IMMEDIATELY",
"Planner Solution Error",
AlertStatus.critical, AlertSize.full,
- Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
+ Priority.HIGHEST, "steerRequired", "chimeRepeated", 1., 3., 4.),
# not loud cancellations (user is in control)
"noTarget": Alert(
@@ -363,6 +378,12 @@ class AlertManager(object):
AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.),
+ "geofenceNoEntry": Alert(
+ "openpilot Unavailable",
+ "Not in Geofenced Area",
+ AlertStatus.normal, AlertSize.mid,
+ Priority.MID, None, "chimeDouble", .4, 2., 3.),
+
"radarCommIssueNoEntry": Alert(
"openpilot Unavailable",
"Radar Error: Restart the Car",
@@ -494,6 +515,7 @@ class AlertManager(object):
self.alert_size = AlertSize.none
self.visual_alert = "none"
self.audible_alert = "none"
+ self.alert_rate = 0.
if ca:
if ca.start_time + ca.duration_sound > cur_time:
@@ -507,3 +529,4 @@ class AlertManager(object):
self.alert_text_2 = ca.alert_text_2
self.alert_status = ca.alert_status
self.alert_size = ca.alert_size
+ self.alert_rate = ca.alert_rate
diff --git a/selfdrive/controls/lib/drive_helpers.py b/selfdrive/controls/lib/drive_helpers.py
index 37a8adff04..10d3eee73d 100644
--- a/selfdrive/controls/lib/drive_helpers.py
+++ b/selfdrive/controls/lib/drive_helpers.py
@@ -1,3 +1,5 @@
+import os
+import signal
from cereal import car
from common.numpy_fast import clip
from selfdrive.config import Conversions as CV
@@ -88,5 +90,19 @@ def update_v_cruise(v_cruise_kph, buttonEvents, enabled):
return v_cruise_kph
-def initialize_v_cruise(v_ego):
+def initialize_v_cruise(v_ego, buttonEvents, v_cruise_last):
+ for b in buttonEvents:
+ # 300kph or above probably means we never had a set speed
+ if b.type == "accelCruise" and v_cruise_last < 300:
+ return v_cruise_last
+
return int(round(max(v_ego * CV.MS_TO_KPH, V_CRUISE_ENABLE_MIN)))
+
+
+def kill_defaultd():
+ # defaultd is used to send can messages when controlsd is off to make car test easier
+ if os.path.isfile("/tmp/defaultd_pid"):
+ with open("/tmp/defaultd_pid") as f:
+ ddpid = int(f.read())
+ print("signalling defaultd with pid %d" % ddpid)
+ os.kill(ddpid, signal.SIGUSR1)
diff --git a/selfdrive/controls/lib/driver_monitor.py b/selfdrive/controls/lib/driver_monitor.py
new file mode 100644
index 0000000000..a593f1091d
--- /dev/null
+++ b/selfdrive/controls/lib/driver_monitor.py
@@ -0,0 +1,121 @@
+import numpy as np
+from common.realtime import sec_since_boot
+from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
+
+_DT = 0.01 # update runs at 100Hz
+_AWARENESS_TIME = 180 # 3 minutes limit without user touching steering wheels make the car enter a terminal status
+_AWARENESS_PRE_TIME = 20. # a first alert is issued 20s before expiration
+_AWARENESS_PROMPT_TIME = 5. # a second alert is issued 5s before start decelerating the car
+_DISTRACTED_TIME = 6.
+_DISTRACTED_PRE_TIME = 4.
+_DISTRACTED_PROMPT_TIME = 2.
+# measured 1 rad in x FOV. 1152x864 is original image, 160x320 is a right crop for model
+_CAMERA_FOV_X = 1. # rad
+_CAMERA_FOV_Y = 0.75 # 4/3 aspect ratio
+# model output refers to center of cropped image, so need to apply the x displacement offset
+_CAMERA_OFFSET_X = 0.3125 #(1152/2 - 0.5*(160*864/320))/1152
+_CAMERA_X_CONV = 0.375 # 160*864/320/1152
+_PITCH_WEIGHT = 1.5 # pitch matters a lot more
+_METRIC_THRESHOLD = 0.4
+_PITCH_POS_ALLOWANCE = 0.08 # rad, to not be too sensitive on positive pitch
+_DTM = 0.2 # driver monitor runs at 5Hz
+_DISTRACTED_FILTER_F = 0.3 # 0.3Hz
+_DISTRACTED_FILTER_K = 2 * np.pi * _DISTRACTED_FILTER_F * _DTM / (1 + 2 * np.pi * _DISTRACTED_FILTER_F * _DTM)
+_PITCH_NATURAL_OFFSET = 0.1 # people don't seem to look straight when they drive relaxed, rather a bit up
+
+
+class _DriverPose():
+ def __init__(self):
+ self.yaw = 0.
+ self.pitch = 0.
+ self.roll = 0.
+ self.yaw_offset = 0.
+ self.pitch_offset = 0.
+
+class DriverStatus():
+ def __init__(self, monitor_on):
+ self.pose = _DriverPose()
+ self.monitor_on = monitor_on
+ self.awareness = 1.
+ self.driver_distracted = False
+ self.driver_distraction_level = 0.
+ self.ts_last_check = 0.
+ self._set_timers()
+
+ def _set_timers(self):
+ if self.monitor_on:
+ self.threshold_pre = _DISTRACTED_PRE_TIME / _DISTRACTED_TIME
+ self.threshold_prompt = _DISTRACTED_PROMPT_TIME / _DISTRACTED_TIME
+ self.step_change = _DT / _DISTRACTED_TIME
+ else:
+ self.threshold_pre = _AWARENESS_PRE_TIME / _AWARENESS_TIME
+ self.threshold_prompt = _AWARENESS_PROMPT_TIME / _AWARENESS_TIME
+ self.step_change = _DT / _AWARENESS_TIME
+
+ def _is_driver_distracted(self, pose):
+ # to be tuned and to learn the driver's normal pose
+ yaw_error = pose.yaw - pose.yaw_offset
+ pitch_error = pose.pitch - pose.pitch_offset - _PITCH_NATURAL_OFFSET
+ # add positive pitch allowance
+ if pitch_error > 0.:
+ pitch_error = max(pitch_error - _PITCH_POS_ALLOWANCE, 0.)
+ pitch_error *= _PITCH_WEIGHT
+ metric = np.sqrt(yaw_error**2 + pitch_error**2)
+ #print "%02.4f" % np.degrees(pose.pitch), "%02.4f" % np.degrees(pitch_error), "%03.4f" % np.degrees(pose.pitch_offset), metric
+ return 1 if metric > _METRIC_THRESHOLD else 0
+
+ def get_pose(self, driver_monitoring, params):
+ ts = sec_since_boot()
+
+ # don's check for param too often as it's a kernel call
+ if ts - self.ts_last_check > 1.:
+ self.monitor_on = params.get("IsDriverMonitoringEnabled") == "1"
+ self._set_timers()
+ self.ts_last_check = ts
+
+ self.pose.pitch = driver_monitoring.descriptor[0]
+ self.pose.yaw = driver_monitoring.descriptor[1]
+ self.pose.roll = driver_monitoring.descriptor[2]
+ self.pose.yaw_offset = (driver_monitoring.descriptor[3] * _CAMERA_X_CONV + _CAMERA_OFFSET_X) * _CAMERA_FOV_X
+ self.pose.pitch_offset = -driver_monitoring.descriptor[4] * _CAMERA_FOV_Y # positive y is down
+ self.driver_distracted = self._is_driver_distracted(self.pose)
+ # first order filter
+ self.driver_distraction_level = (1. - _DISTRACTED_FILTER_K) * self.driver_distraction_level + \
+ _DISTRACTED_FILTER_K * self.driver_distracted
+
+ def update(self, events, driver_engaged, ctrl_active, standstill):
+
+ driver_engaged |= (self.driver_distraction_level < 0.37 and self.monitor_on)
+
+ if (driver_engaged and self.awareness > 0.) or not ctrl_active:
+ # always reset if driver is in control (unless we are in red alert state) or op isn't active
+ self.awareness = 1.
+
+ if (not self.monitor_on or (self.driver_distraction_level > 0.63 and self.driver_distracted)) and \
+ not (standstill and self.awareness - self.step_change <= self.threshold_prompt):
+ self.awareness = max(self.awareness - self.step_change, -0.1)
+
+ if self.awareness <= 0.:
+ # terminal red alert: disengagement required
+ events.append(create_event('driverDistracted', [ET.WARNING]))
+ elif self.awareness <= self.threshold_prompt:
+ # prompt orange alert
+ events.append(create_event('promptDriverDistracted', [ET.WARNING]))
+ elif self.awareness <= self.threshold_pre:
+ # pre green alert
+ events.append(create_event('preDriverDistracted', [ET.WARNING]))
+
+ return events
+
+
+if __name__ == "__main__":
+ ds = DriverStatus(True)
+ ds.driver_distraction_level = 1.
+ ds.driver_distracted = 1
+ for i in range(1000):
+ ds.update([], False, True, True)
+ print(ds.awareness, ds.driver_distracted, ds.driver_distraction_level)
+ ds.update([], True, True, False)
+ print(ds.awareness, ds.driver_distracted, ds.driver_distraction_level)
+
+
diff --git a/selfdrive/controls/lib/latcontrol.py b/selfdrive/controls/lib/latcontrol.py
index 101b8368fa..e1fd68b90d 100644
--- a/selfdrive/controls/lib/latcontrol.py
+++ b/selfdrive/controls/lib/latcontrol.py
@@ -28,12 +28,11 @@ class LatControl(object):
(VM.CP.steerKiBP, VM.CP.steerKiV),
k_f=VM.CP.steerKf, pos_limit=1.0)
self.last_cloudlog_t = 0.0
- self.setup_mpc()
+ self.setup_mpc(VM.CP.steerRateCost)
- def setup_mpc(self):
+ def setup_mpc(self, steer_rate_cost):
self.libmpc = libmpc_py.libmpc
- self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE,
- MPC_COST_LAT.HEADING, MPC_COST_LAT.STEER_RATE)
+ self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, steer_rate_cost)
self.mpc_solution = libmpc_py.ffi.new("log_t *")
self.cur_state = libmpc_py.ffi.new("state_t *")
@@ -91,7 +90,7 @@ class LatControl(object):
self.mpc_nans = np.any(np.isnan(list(self.mpc_solution[0].delta)))
t = sec_since_boot()
if self.mpc_nans:
- self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, MPC_COST_LAT.STEER_RATE)
+ self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, VM.CP.steerRateCost)
self.cur_state[0].delta = math.radians(angle_steers) / VM.CP.steerRatio
if t > self.last_cloudlog_t + 5.0:
@@ -113,7 +112,9 @@ class LatControl(object):
steer_feedforward = self.angle_steers_des # feedforward desired angle
if VM.CP.steerControlType == car.CarParams.SteerControlType.torque:
steer_feedforward *= v_ego**2 # proportional to realigning tire momentum (~ lateral accel)
- output_steer = self.pid.update(self.angle_steers_des, angle_steers, check_saturation=(v_ego > 10), override=steer_override, feedforward=steer_feedforward, speed=v_ego)
+ deadzone = 0.0
+ output_steer = self.pid.update(self.angle_steers_des, angle_steers, check_saturation=(v_ego > 10), override=steer_override,
+ feedforward=steer_feedforward, speed=v_ego, deadzone=deadzone)
self.sat_flag = self.pid.saturated
return output_steer, float(self.angle_steers_des)
diff --git a/selfdrive/controls/lib/pathplanner.py b/selfdrive/controls/lib/pathplanner.py
index ab3d8d3db4..178b5e6dbb 100644
--- a/selfdrive/controls/lib/pathplanner.py
+++ b/selfdrive/controls/lib/pathplanner.py
@@ -1,7 +1,7 @@
from common.numpy_fast import interp
from selfdrive.controls.lib.latcontrol_helpers import model_polyfit, calc_desired_path, compute_path_pinv
-CAMERA_OFFSET = 0.12 # ~12cm from center car to camera
+CAMERA_OFFSET = 0.06 # m from center car to camera
class PathPlanner(object):
def __init__(self):
diff --git a/selfdrive/controls/lib/planner.py b/selfdrive/controls/lib/planner.py
index 5beec543e7..11d1d847db 100755
--- a/selfdrive/controls/lib/planner.py
+++ b/selfdrive/controls/lib/planner.py
@@ -22,7 +22,6 @@ _DT = 0.01 # 100Hz
_DT_MPC = 0.2 # 5Hz
MAX_SPEED_ERROR = 2.0
AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted
-_DEBUG = False
_LEAD_ACCEL_TAU = 1.5
GPS_PLANNER_ADDR = "192.168.5.1"
@@ -315,10 +314,11 @@ class Planner(object):
slowest = min(solutions, key=solutions.get)
- if _DEBUG:
- print "D_SOL", solutions, slowest, self.v_acc_sol, self.a_acc_sol
- print "D_V", self.mpc1.v_mpc, self.mpc2.v_mpc, self.v_cruise
- print "D_A", self.mpc1.a_mpc, self.mpc2.a_mpc, self.a_cruise
+ """
+ print "D_SOL", solutions, slowest, self.v_acc_sol, self.a_acc_sol
+ print "D_V", self.mpc1.v_mpc, self.mpc2.v_mpc, self.v_cruise
+ print "D_A", self.mpc1.a_mpc, self.mpc2.a_mpc, self.a_cruise
+ """
self.longitudinalPlanSource = slowest
@@ -336,7 +336,7 @@ class Planner(object):
self.v_acc_future = min([self.mpc1.v_mpc_future, self.mpc2.v_mpc_future, v_cruise_setpoint])
# this runs whenever we get a packet that can change the plan
- def update(self, CS, LaC, LoC, v_cruise_kph, user_distracted):
+ def update(self, CS, LaC, LoC, v_cruise_kph, force_slow_decel):
cur_time = sec_since_boot()
v_cruise_setpoint = v_cruise_kph * CV.KPH_TO_MS
@@ -396,8 +396,9 @@ class Planner(object):
# TODO: make a separate lookup for jerk tuning
jerk_limits = [min(-0.1, accel_limits[0]), max(0.1, accel_limits[1])]
accel_limits = limit_accel_in_turns(CS.vEgo, CS.steeringAngle, accel_limits, self.CP)
- if user_distracted:
- # if user is not responsive to awareness alerts, then start a smooth deceleration
+
+ if force_slow_decel:
+ # if required so, force a smooth deceleration
accel_limits[1] = min(accel_limits[1], AWARENESS_DECEL)
accel_limits[0] = min(accel_limits[0], accel_limits[1])
diff --git a/selfdrive/controls/lib/radar_helpers.py b/selfdrive/controls/lib/radar_helpers.py
index 55a6b5b924..b5ee51e485 100644
--- a/selfdrive/controls/lib/radar_helpers.py
+++ b/selfdrive/controls/lib/radar_helpers.py
@@ -25,12 +25,12 @@ v_oncoming_thr = -3.9 # needs to be a bit lower in abs value than v_stationary
v_ego_stationary = 4. # no stationary object flag below this speed
# Lead Kalman Filter params
-_VLEAD_A = np.matrix([[1.0, ts], [0.0, 1.0]])
-_VLEAD_C = np.matrix([1.0, 0.0])
+_VLEAD_A = [[1.0, ts], [0.0, 1.0]]
+_VLEAD_C = [[1.0, 0.0]]
#_VLEAD_Q = np.matrix([[10., 0.0], [0.0, 100.]])
#_VLEAD_R = 1e3
#_VLEAD_K = np.matrix([[ 0.05705578], [ 0.03073241]])
-_VLEAD_K = np.matrix([[ 0.1988689 ], [ 0.28555364]])
+_VLEAD_K = [[ 0.1988689 ], [ 0.28555364]]
class Track(object):
@@ -65,7 +65,7 @@ class Track(object):
self.vision = False
self.aRel = 0. # nidec gives no information about this
self.vLat = 0.
- self.kf = KF1D(np.matrix([[self.vLead], [0.0]]), _VLEAD_A, _VLEAD_C, _VLEAD_K)
+ self.kf = KF1D([[self.vLead], [0.0]], _VLEAD_A, _VLEAD_C, _VLEAD_K)
else:
# estimate acceleration
# TODO: use Kalman filter
@@ -82,8 +82,8 @@ class Track(object):
self.cnt += 1
- self.vLeadK = float(self.kf.x[SPEED])
- self.aLeadK = float(self.kf.x[ACCEL])
+ self.vLeadK = float(self.kf.x[SPEED][0])
+ self.aLeadK = float(self.kf.x[ACCEL][0])
if self.stationary:
# stationary objects can become non stationary, but not the other way around
@@ -200,18 +200,20 @@ class Cluster(object):
def oncoming(self):
return all([t.oncoming for t in self.tracks])
- def toLive20(self, lead):
- lead.dRel = float(self.dRel) - RDR_TO_LDR
- lead.yRel = float(self.yRel)
- lead.vRel = float(self.vRel)
- lead.aRel = float(self.aRel)
- lead.vLead = float(self.vLead)
- lead.dPath = float(self.dPath)
- lead.vLat = float(self.vLat)
- lead.vLeadK = float(self.vLeadK)
- lead.aLeadK = float(self.aLeadK)
- lead.status = True
- lead.fcw = self.is_potential_fcw()
+ def toLive20(self):
+ return {
+ "dRel": float(self.dRel) - RDR_TO_LDR,
+ "yRel": float(self.yRel),
+ "vRel": float(self.vRel),
+ "aRel": float(self.aRel),
+ "vLead": float(self.vLead),
+ "dPath": float(self.dPath),
+ "vLat": float(self.vLat),
+ "vLeadK": float(self.vLeadK),
+ "aLeadK": float(self.aLeadK),
+ "status": True,
+ "fcw": self.is_potential_fcw(),
+ }
def __str__(self):
ret = "x: %4.1f y: %4.1f v: %4.1f a: %4.1f d: %4.2f" % (self.dRel, self.yRel, self.vRel, self.aLeadK, self.dPath)
diff --git a/selfdrive/controls/lib/vehicle_model.py b/selfdrive/controls/lib/vehicle_model.py
index d4a954c9d7..df3bb0a967 100755
--- a/selfdrive/controls/lib/vehicle_model.py
+++ b/selfdrive/controls/lib/vehicle_model.py
@@ -97,8 +97,9 @@ if __name__ == '__main__':
# load car params
#CP = CarInterface.get_params("TOYOTA PRIUS 2017", {})
CP = CarInterface.get_params("HONDA CIVIC 2016 TOURING", {})
- print CP
+ #print CP
VM = VehicleModel(CP)
- print VM.steady_state_sol(.1, 0.15)
- print calc_slip_factor(VM)
- print VM.yaw_rate(0.2*np.pi/180, 32.) * 180./np.pi
+ #print VM.steady_state_sol(.1, 0.15)
+ #print calc_slip_factor(VM)
+ #print VM.yaw_rate(3.*np.pi/180, 32.) * 180./np.pi
+ #print VM.curvature_factor(32)
diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py
index 00c34557d6..5f69085cf2 100755
--- a/selfdrive/controls/radard.py
+++ b/selfdrive/controls/radard.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+import gc
import zmq
import numpy as np
import numpy.matlib
@@ -44,6 +45,7 @@ class EKFV1D(EKF):
# fuses camera and radar data for best lead detection
def radard_thread(gctx=None):
+ gc.disable()
set_realtime_priority(2)
# wait for stats about the car to come in from controls
@@ -195,9 +197,9 @@ def radard_thread(gctx=None):
tracks[fused_id].update_vision_fusion()
if DEBUG:
- print "NEW CYCLE"
+ print("NEW CYCLE")
if VISION_POINT in ar_pts:
- print "vision", ar_pts[VISION_POINT]
+ print("vision", ar_pts[VISION_POINT])
idens = tracks.keys()
track_pts = np.array([tracks[iden].get_key_for_cluster() for iden in idens])
@@ -223,7 +225,7 @@ def radard_thread(gctx=None):
if DEBUG:
for i in clusters:
- print i
+ print(i)
# *** extract the lead car ***
lead_clusters = [c for c in clusters
if c.is_potential_lead(v_ego)]
@@ -244,9 +246,9 @@ def radard_thread(gctx=None):
dat.live20.radarErrors = list(rr.errors)
dat.live20.l100MonoTime = last_l100_ts
if lead_len > 0:
- lead_clusters[0].toLive20(dat.live20.leadOne)
+ dat.live20.leadOne = lead_clusters[0].toLive20()
if lead2_len > 0:
- lead2_clusters[0].toLive20(dat.live20.leadTwo)
+ dat.live20.leadTwo = lead2_clusters[0].toLive20()
else:
dat.live20.leadTwo.status = False
else:
@@ -261,20 +263,22 @@ def radard_thread(gctx=None):
for cnt, ids in enumerate(tracks.keys()):
if DEBUG:
- print "id: %4.0f x: %4.1f y: %4.1f vr: %4.1f d: %4.1f va: %4.1f vl: %4.1f vlk: %4.1f alk: %4.1f s: %1.0f v: %1.0f" % \
+ print("id: %4.0f x: %4.1f y: %4.1f vr: %4.1f d: %4.1f va: %4.1f vl: %4.1f vlk: %4.1f alk: %4.1f s: %1.0f v: %1.0f" % \
(ids, tracks[ids].dRel, tracks[ids].yRel, tracks[ids].vRel,
tracks[ids].dPath, tracks[ids].vLat,
tracks[ids].vLead, tracks[ids].vLeadK,
tracks[ids].aLeadK,
tracks[ids].stationary,
- tracks[ids].measured)
- dat.liveTracks[cnt].trackId = ids
- dat.liveTracks[cnt].dRel = float(tracks[ids].dRel)
- dat.liveTracks[cnt].yRel = float(tracks[ids].yRel)
- dat.liveTracks[cnt].vRel = float(tracks[ids].vRel)
- dat.liveTracks[cnt].aRel = float(tracks[ids].aRel)
- dat.liveTracks[cnt].stationary = tracks[ids].stationary
- dat.liveTracks[cnt].oncoming = tracks[ids].oncoming
+ tracks[ids].measured))
+ dat.liveTracks[cnt] = {
+ "trackId": ids,
+ "dRel": float(tracks[ids].dRel),
+ "yRel": float(tracks[ids].yRel),
+ "vRel": float(tracks[ids].vRel),
+ "aRel": float(tracks[ids].aRel),
+ "stationary": tracks[ids].stationary,
+ "oncoming": tracks[ids].oncoming,
+ }
liveTracks.send(dat.to_bytes())
rk.monitor_time()
diff --git a/selfdrive/debug/getframes/getframes.py b/selfdrive/debug/getframes/getframes.py
index 8ab2811d54..292368d6a9 100755
--- a/selfdrive/debug/getframes/getframes.py
+++ b/selfdrive/debug/getframes/getframes.py
@@ -14,9 +14,10 @@ ffi = FFI()
ffi.cdef("""
typedef enum VisionStreamType {
- VISION_STREAM_UI_BACK,
- VISION_STREAM_UI_FRONT,
+ VISION_STREAM_RGB_BACK,
+ VISION_STREAM_RGB_FRONT,
VISION_STREAM_YUV,
+ VISION_STREAM_YUV_FRONT,
VISION_STREAM_MAX,
} VisionStreamType;
@@ -47,12 +48,15 @@ typedef struct VIPCBuf {
} VIPCBuf;
typedef struct VIPCBufExtra {
- uint32_t frame_id; // only for yuv
+ // only for yuv
+ uint32_t frame_id;
+ uint64_t timestamp_eof;
} VIPCBufExtra;
typedef struct VisionStream {
int ipc_fd;
int last_idx;
+ int last_type;
int num_bufs;
VisionStreamBufs bufs_info;
VIPCBuf *bufs;
@@ -68,10 +72,16 @@ void visionstream_destroy(VisionStream *s);
clib = ffi.dlopen(os.path.join(gf_dir, "libvisionipc.so"))
-def getframes():
+def getframes(front=False):
s = ffi.new("VisionStream*")
buf_info = ffi.new("VisionStreamBufs*")
- err = clib.visionstream_init(s, clib.VISION_STREAM_UI_BACK, True, buf_info)
+
+ if front:
+ stream_type = clib.VISION_STREAM_RGB_FRONT
+ else:
+ stream_type = clib.VISION_STREAM_RGB_BACK
+
+ err = clib.visionstream_init(s, stream_type, True, buf_info)
assert err == 0
w = buf_info.width
diff --git a/selfdrive/locationd/locationd_dummy.py b/selfdrive/locationd/locationd_dummy.py
deleted file mode 100755
index 2c44932f1e..0000000000
--- a/selfdrive/locationd/locationd_dummy.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python
-import zmq
-from copy import copy
-from selfdrive import messaging
-from selfdrive.services import service_list
-from cereal import log
-
-from common.transformations.coordinates import geodetic2ecef
-
-def main(gctx=None):
- context = zmq.Context()
- poller = zmq.Poller()
- gps_sock = messaging.sub_sock(context, service_list['gpsLocation'].port, poller)
- gps_ext_sock = messaging.sub_sock(context, service_list['gpsLocationExternal'].port, poller)
- app_sock = messaging.sub_sock(context, service_list['applanixLocation'].port, poller)
- loc_sock = messaging.pub_sock(context, service_list['liveLocation'].port)
-
- last_ext, last_gps, last_app = -1, -1, -1
- # 5 sec
- max_gap = 5*1e9
- preferred_type = None
-
- while 1:
- for sock, event in poller.poll(500):
- if sock is app_sock:
- msg = messaging.recv_one(sock)
- last_app = msg.logMonoTime
- this_type = 'app'
- if sock is gps_sock:
- msg = messaging.recv_one(sock)
- gps_pkt = msg.gpsLocation
- last_gps = msg.logMonoTime
- this_type = 'gps'
- if sock is gps_ext_sock:
- msg = messaging.recv_one(sock)
- gps_pkt = msg.gpsLocationExternal
- last_ext = msg.logMonoTime
- this_type = 'ext'
-
- last = max(last_gps, last_ext, last_app)
-
- if last_app > last - max_gap:
- new_preferred_type = 'app'
- elif last_ext > last - max_gap:
- new_preferred_type = 'ext'
- else:
- new_preferred_type = 'gps'
-
- if preferred_type != new_preferred_type:
- print "switching from %s to %s" % (preferred_type, new_preferred_type)
- preferred_type = new_preferred_type
-
- if this_type == preferred_type:
- new_msg = messaging.new_message()
- if this_type == 'app':
- # straight proxy the applanix
- new_msg.init('liveLocation')
- new_msg.liveLocation = copy(msg.applanixLocation)
- else:
- new_msg.logMonoTime = msg.logMonoTime
- new_msg.init('liveLocation')
- pkt = new_msg.liveLocation
- pkt.lat = gps_pkt.latitude
- pkt.lon = gps_pkt.longitude
- pkt.alt = gps_pkt.altitude
- pkt.speed = gps_pkt.speed
- pkt.heading = gps_pkt.bearing
- pkt.positionECEF = [float(x) for x in geodetic2ecef([pkt.lat, pkt.lon, pkt.alt])]
- pkt.source = log.LiveLocationData.SensorSource.dummy
- loc_sock.send(new_msg.to_bytes())
-
-if __name__ == '__main__':
- main()
diff --git a/selfdrive/loggerd/loggerd b/selfdrive/loggerd/loggerd
index 34b40b5647..7ed8ac45d5 100755
Binary files a/selfdrive/loggerd/loggerd and b/selfdrive/loggerd/loggerd differ
diff --git a/selfdrive/manager.py b/selfdrive/manager.py
index e425304780..5c2d3a4108 100755
--- a/selfdrive/manager.py
+++ b/selfdrive/manager.py
@@ -20,7 +20,7 @@ if __name__ == "__main__":
copyfile(os.path.join(BASEDIR, "scripts", "continue.sh"), "/data/data/com.termux/files/continue.sh")
# run the updater
- print "Starting NEOS updater"
+ print("Starting NEOS updater")
subprocess.check_call(["git", "clean", "-xdf"], cwd=BASEDIR)
os.system(os.path.join(BASEDIR, "installer", "updater", "updater"))
raise Exception("NEOS outdated")
@@ -62,35 +62,29 @@ import subprocess
import traceback
from multiprocessing import Process
-EON = os.path.exists("/EON")
-if EON and os.path.exists(os.path.join(BASEDIR, "vpn")):
- print "installing vpn"
- os.system(os.path.join(BASEDIR, "vpn", "install.sh"))
-
import zmq
from setproctitle import setproctitle #pylint: disable=no-name-in-module
from common.params import Params
-from common.realtime import sec_since_boot
+import cereal
+ThermalStatus = cereal.log.ThermalData.ThermalStatus
from selfdrive.services import service_list
from selfdrive.swaglog import cloudlog
import selfdrive.messaging as messaging
-from selfdrive.thermal import read_thermal
from selfdrive.registration import register
-from selfdrive.version import version, dirty, training_version
+from selfdrive.version import version, dirty
import selfdrive.crash as crash
from selfdrive.loggerd.config import ROOT
-
# comment out anything you don't want to run
managed_processes = {
+ "thermald": "selfdrive.thermald",
"uploader": "selfdrive.loggerd.uploader",
"controlsd": "selfdrive.controls.controlsd",
"radard": "selfdrive.controls.radard",
"ubloxd": "selfdrive.locationd.ubloxd",
- "locationd_dummy": "selfdrive.locationd.locationd_dummy",
"loggerd": ("selfdrive/loggerd", ["./loggerd"]),
"logmessaged": "selfdrive.logmessaged",
"tombstoned": "selfdrive.tombstoned",
@@ -102,10 +96,9 @@ managed_processes = {
"visiond": ("selfdrive/visiond", ["./visiond"]),
"sensord": ("selfdrive/sensord", ["./sensord"]),
"gpsd": ("selfdrive/sensord", ["./gpsd"]),
- #"orbd": ("selfdrive/orbd", ["./orbd_wrapper.sh"]),
"updated": "selfdrive.updated",
- #"gpsplanner": "selfdrive.controls.gps_plannerd",
}
+android_packages = ("ai.comma.plus.offroad", "ai.comma.plus.frame")
running = {}
def get_running():
@@ -118,6 +111,7 @@ unkillable_processes = ['visiond']
interrupt_processes = []
persistent_processes = [
+ 'thermald',
'logmessaged',
'logcatd',
'tombstoned',
@@ -125,7 +119,6 @@ persistent_processes = [
'ui',
'gpsd',
'ubloxd',
- 'locationd_dummy',
'updated',
]
@@ -137,12 +130,11 @@ car_started_processes = [
'visiond',
'proclogd',
'orbd',
- # 'gpsplanner,
]
def register_managed_process(name, desc, car_started=False):
global managed_processes, car_started_processes, persistent_processes
- print "registering", name
+ print("registering %s" % name)
managed_processes[name] = desc
if car_started:
car_started_processes.append(name)
@@ -181,7 +173,7 @@ def start_managed_process(name):
if name in running or name not in managed_processes:
return
proc = managed_processes[name]
- if isinstance(proc, basestring):
+ if isinstance(proc, str):
cloudlog.info("starting python %s" % proc)
running[name] = Process(name=name, target=launcher, args=(proc, gctx))
else:
@@ -193,7 +185,7 @@ def start_managed_process(name):
def prepare_managed_process(p):
proc = managed_processes[p]
- if isinstance(proc, basestring):
+ if isinstance(proc, str):
# import this python
cloudlog.info("preimporting %s" % proc)
importlib.import_module(proc)
@@ -238,13 +230,16 @@ def kill_managed_process(name):
cloudlog.info("%s is dead with %d" % (name, running[name].exitcode))
del running[name]
+def pm_apply_packages(cmd):
+ for p in android_packages:
+ system("pm %s %s" % (cmd, p))
+
def cleanup_all_processes(signal, frame):
cloudlog.info("caught ctrl-c %s %s" % (signal, frame))
- for p in ("com.waze", "com.spotify.music", "ai.comma.plus.offroad", "ai.comma.plus.frame"):
- system("am force-stop %s" % p)
+ pm_apply_packages('disable')
- for name in running.keys():
+ for name in list(running.keys()):
kill_managed_process(name)
cloudlog.info("everything is dead")
@@ -271,13 +266,13 @@ def manager_init(should_register=True):
if not dirty:
os.environ['CLEAN'] = '1'
- cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, is_eon=EON)
+ cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, is_eon=True)
crash.bind_user(id=dongle_id)
- crash.bind_extra(version=version, dirty=dirty, is_eon=EON)
+ crash.bind_extra(version=version, dirty=dirty, is_eon=True)
os.umask(0)
try:
- os.mkdir(ROOT, 0777)
+ os.mkdir(ROOT, 0o777)
except OSError:
pass
@@ -288,119 +283,17 @@ def system(cmd):
try:
cloudlog.info("running %s" % cmd)
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
- except subprocess.CalledProcessError, e:
+ except subprocess.CalledProcessError as e:
cloudlog.event("running failed",
cmd=e.cmd,
output=e.output[-1024:],
returncode=e.returncode)
-LEON = False
-def setup_eon_fan():
- global LEON
-
- if not EON:
- return
-
- os.system("echo 2 > /sys/module/dwc3_msm/parameters/otg_switch")
-
- from smbus2 import SMBus
- bus = SMBus(7, force=True)
- try:
- bus.write_byte_data(0x21, 0x10, 0xf) # mask all interrupts
- bus.write_byte_data(0x21, 0x03, 0x1) # set drive current and global interrupt disable
- bus.write_byte_data(0x21, 0x02, 0x2) # needed?
- bus.write_byte_data(0x21, 0x04, 0x4) # manual override source
- except IOError:
- print "LEON detected"
- #os.system("echo 1 > /sys/devices/soc/6a00000.ssusb/power_supply/usb/usb_otg")
- LEON = True
- bus.close()
-
-last_eon_fan_val = None
-def set_eon_fan(val):
- global LEON, last_eon_fan_val
-
- if not EON:
- return
-
- from smbus2 import SMBus
- if last_eon_fan_val is None or last_eon_fan_val != val:
- bus = SMBus(7, force=True)
- if LEON:
- i = [0x1, 0x3 | 0, 0x3 | 0x08, 0x3 | 0x10][val]
- bus.write_i2c_block_data(0x3d, 0, [i])
- else:
- bus.write_byte_data(0x21, 0x04, 0x2)
- bus.write_byte_data(0x21, 0x03, (val*2)+1)
- bus.write_byte_data(0x21, 0x04, 0x4)
- bus.close()
- last_eon_fan_val = val
-
-
-# temp thresholds to control fan speed - high hysteresis
-_TEMP_THRS_H = [50., 65., 80., 10000]
-# temp thresholds to control fan speed - low hysteresis
-_TEMP_THRS_L = [42.5, 57.5, 72.5, 10000]
-# fan speed options
-_FAN_SPEEDS = [0, 16384, 32768, 65535]
-# max fan speed only allowed if battery if hot
-_BAT_TEMP_THERSHOLD = 45.
-
-def handle_fan(max_temp, bat_temp, fan_speed):
- new_speed_h = next(speed for speed, temp_h in zip(_FAN_SPEEDS, _TEMP_THRS_H) if temp_h > max_temp)
- new_speed_l = next(speed for speed, temp_l in zip(_FAN_SPEEDS, _TEMP_THRS_L) if temp_l > max_temp)
-
- if new_speed_h > fan_speed:
- # update speed if using the high thresholds results in fan speed increment
- fan_speed = new_speed_h
- elif new_speed_l < fan_speed:
- # update speed if using the low thresholds results in fan speed decrement
- fan_speed = new_speed_l
-
- if bat_temp < _BAT_TEMP_THERSHOLD:
- # no max fan speed unless battery is hot
- fan_speed = min(fan_speed, _FAN_SPEEDS[-2])
-
- set_eon_fan(fan_speed/16384)
-
- return fan_speed
-
-class LocationStarter(object):
- def __init__(self):
- self.last_good_loc = 0
- def update(self, started_ts, location):
- rt = sec_since_boot()
-
- if location is None or location.accuracy > 50 or location.speed < 2:
- # bad location, stop if we havent gotten a location in a while
- # dont stop if we're been going for less than a minute
- if started_ts:
- if rt-self.last_good_loc > 60. and rt-started_ts > 60:
- cloudlog.event("location_stop",
- ts=rt,
- started_ts=started_ts,
- last_good_loc=self.last_good_loc,
- location=location.to_dict() if location else None)
- return False
- else:
- return True
- else:
- return False
-
- self.last_good_loc = rt
-
- if started_ts:
- return True
- else:
- cloudlog.event("location_start", location=location.to_dict() if location else None)
- return location.speed*3.6 > 10
def manager_thread():
# now loop
context = zmq.Context()
- thermal_sock = messaging.pub_sock(context, service_list['thermal'].port)
- health_sock = messaging.sub_sock(context, service_list['health'].port)
- location_sock = messaging.sub_sock(context, service_list['gpsLocation'].port)
+ thermal_sock = messaging.sub_sock(context, service_list['thermal'].port)
cloudlog.info("manager start")
cloudlog.info({"environ": os.environ})
@@ -409,156 +302,47 @@ def manager_thread():
start_managed_process(p)
# start frame
+ pm_apply_packages('enable')
system("am start -n ai.comma.plus.frame/.MainActivity")
- # do this before panda flashing
- setup_eon_fan()
-
if os.getenv("NOBOARD") is None:
start_managed_process("pandad")
params = Params()
-
- passive_starter = LocationStarter()
-
- started_ts = None
- off_ts = None
logger_dead = False
- count = 0
- fan_speed = 0
- ignition_seen = False
- started_seen = False
- panda_seen = False
-
- health_sock.RCVTIMEO = 1500
while 1:
# get health of board, log this in "thermal"
- td = messaging.recv_sock(health_sock, wait=True)
- location = messaging.recv_sock(location_sock)
-
- location = location.gpsLocation if location else None
-
- print td
-
- # replace thermald
- msg = read_thermal()
-
- # loggerd is gated based on free space
- statvfs = os.statvfs(ROOT)
- avail = (statvfs.f_bavail * 1.0)/statvfs.f_blocks
-
- # thermal message now also includes free space
- msg.thermal.freeSpace = avail
- with open("/sys/class/power_supply/battery/capacity") as f:
- msg.thermal.batteryPercent = int(f.read())
- with open("/sys/class/power_supply/battery/status") as f:
- msg.thermal.batteryStatus = f.read().strip()
- with open("/sys/class/power_supply/usb/online") as f:
- msg.thermal.usbOnline = bool(int(f.read()))
-
- # TODO: add car battery voltage check
- max_temp = max(msg.thermal.cpu0, msg.thermal.cpu1,
- msg.thermal.cpu2, msg.thermal.cpu3) / 10.0
- bat_temp = msg.thermal.bat/1000.
- fan_speed = handle_fan(max_temp, bat_temp, fan_speed)
- msg.thermal.fanSpeed = fan_speed
-
- msg.thermal.started = started_ts is not None
- msg.thermal.startedTs = int(1e9*(started_ts or 0))
-
- thermal_sock.send(msg.to_bytes())
- print msg
+ msg = messaging.recv_sock(thermal_sock, wait=True)
# uploader is gated based on the phone temperature
- if max_temp > 85.0:
- cloudlog.warning("over temp: %r", max_temp)
+ if msg.thermal.thermalStatus >= ThermalStatus.yellow:
kill_managed_process("uploader")
- elif max_temp < 70.0:
+ else:
start_managed_process("uploader")
- if avail < 0.05:
+ if msg.thermal.freeSpace < 0.05:
logger_dead = True
- # start constellation of processes when the car starts
- ignition = td is not None and td.health.started
- ignition_seen = ignition_seen or ignition
-
- # add voltage check for ignition
- if not ignition_seen and td is not None and td.health.voltage > 13500:
- ignition = True
-
- do_uninstall = params.get("DoUninstall") == "1"
- accepted_terms = params.get("HasAcceptedTerms") == "1"
- completed_training = params.get("CompletedTrainingVersion") == training_version
-
- should_start = ignition
-
- # have we seen a panda?
- panda_seen = panda_seen or td is not None
-
- # start on gps movement if we haven't seen ignition and are in passive mode
- should_start = should_start or (not (ignition_seen and td) # seen ignition and panda is connected
- and params.get("Passive") == "1"
- and passive_starter.update(started_ts, location))
-
- # with 2% left, we killall, otherwise the phone will take a long time to boot
- should_start = should_start and avail > 0.02
-
- # require usb power
- should_start = should_start and msg.thermal.usbOnline
-
- should_start = should_start and accepted_terms and completed_training and (not do_uninstall)
-
- # if any CPU gets above 107 or the battery gets above 63, kill all processes
- # controls will warn with CPU above 95 or battery above 60
- if max_temp > 107.0 or msg.thermal.bat >= 63000:
- # TODO: Add a better warning when this is happening
- should_start = False
-
- if should_start:
- off_ts = None
- if started_ts is None:
- params.car_start()
- started_ts = sec_since_boot()
- started_seen = True
+ if msg.thermal.started:
for p in car_started_processes:
if p == "loggerd" and logger_dead:
kill_managed_process(p)
else:
start_managed_process(p)
else:
- started_ts = None
- if off_ts is None:
- off_ts = sec_since_boot()
logger_dead = False
for p in car_started_processes:
kill_managed_process(p)
- # shutdown if the battery gets lower than 3%, t's discharging, we aren't running for
- # more than a minute but we were running
- if msg.thermal.batteryPercent < 3 and msg.thermal.batteryStatus == "Discharging" and \
- started_seen and (sec_since_boot() - off_ts) > 60:
- os.system('LD_LIBRARY_PATH="" svc power shutdown')
-
# check the status of all processes, did any of them die?
for p in running:
cloudlog.debug(" running %s %s" % (p, running[p]))
- # report to server once per minute
- if (count%60) == 0:
- cloudlog.event("STATUS_PACKET",
- running=running.keys(),
- count=count,
- health=(td.to_dict() if td else None),
- location=(location.to_dict() if location else None),
- thermal=msg.to_dict())
-
- if do_uninstall:
+ # is this still needed?
+ if params.get("DoUninstall") == "1":
break
- count += 1
-
def get_installed_apks():
dat = subprocess.check_output(["pm", "list", "packages", "-f"]).strip().split("\n")
ret = {}
@@ -578,19 +362,10 @@ def install_apk(path):
return ret == 0
def update_apks():
- # patch apks
- if os.getenv("PREPAREONLY"):
- # assume we have internet, download too
- patched = subprocess.call([os.path.join(BASEDIR, "apk/external/patcher.py")])
- else:
- patched = subprocess.call([os.path.join(BASEDIR, "apk/external/patcher.py"), "patch"])
- cloudlog.info("patcher: %r" % (patched,))
-
# install apks
installed = get_installed_apks()
- install_apks = (glob.glob(os.path.join(BASEDIR, "apk/*.apk"))
- + glob.glob(os.path.join(BASEDIR, "apk/external/out/*.apk")))
+ install_apks = glob.glob(os.path.join(BASEDIR, "apk/*.apk"))
for apk in install_apks:
app = os.path.basename(apk)[:-4]
if app not in installed:
@@ -601,8 +376,6 @@ def update_apks():
for app in installed.iterkeys():
apk_path = os.path.join(BASEDIR, "apk/"+app+".apk")
- if not os.path.exists(apk_path):
- apk_path = os.path.join(BASEDIR, "apk/external/out/"+app+".apk")
if not os.path.exists(apk_path):
continue
@@ -624,10 +397,12 @@ def update_apks():
assert success
def manager_update():
+ if os.path.exists(os.path.join(BASEDIR, "vpn")):
+ cloudlog.info("installing vpn")
+ os.system(os.path.join(BASEDIR, "vpn", "install.sh"))
update_apks()
def manager_prepare():
-
# build cereal first
subprocess.check_call(["make", "-j4"], cwd=os.path.join(BASEDIR, "cereal"))
@@ -664,13 +439,8 @@ def main():
if os.getenv("NOCONTROL") is not None:
del managed_processes['controlsd']
del managed_processes['radard']
-
- # disable this until we use it
- """
- if os.path.isfile('logserver/logserver.py'):
- managed_processes["logserver"] = "selfdrive.logserver.wsgi"
- persistent_processes.append("logserver")
- """
+ if os.getenv("DEFAULTD") is not None:
+ managed_processes["controlsd"] = "selfdrive.controls.defaultd"
# support additional internal only extensions
try:
@@ -687,14 +457,16 @@ def main():
params.put("IsMetric", "0")
if params.get("RecordFront") is None:
params.put("RecordFront", "0")
- if params.get("IsRearViewMirror") is None:
- params.put("IsRearViewMirror", "0")
if params.get("IsFcwEnabled") is None:
params.put("IsFcwEnabled", "1")
if params.get("HasAcceptedTerms") is None:
params.put("HasAcceptedTerms", "0")
if params.get("IsUploadVideoOverCellularEnabled") is None:
params.put("IsUploadVideoOverCellularEnabled", "1")
+ if params.get("IsDriverMonitoringEnabled") is None:
+ params.put("IsDriverMonitoringEnabled", "0")
+ if params.get("IsGeofenceEnabled") is None:
+ params.put("IsGeofenceEnabled", "-1")
# is this chffrplus?
if os.getenv("PASSIVE") is not None:
@@ -740,3 +512,4 @@ if __name__ == "__main__":
main()
# manual exit because we are forked
sys.exit(0)
+
diff --git a/selfdrive/messaging.py b/selfdrive/messaging.py
index 119e0d68a4..4811f93454 100644
--- a/selfdrive/messaging.py
+++ b/selfdrive/messaging.py
@@ -18,7 +18,7 @@ def sub_sock(context, port, poller=None, addr="127.0.0.1", conflate=False):
if conflate:
sock.setsockopt(zmq.CONFLATE, 1)
sock.connect("tcp://%s:%d" % (addr, port))
- sock.setsockopt(zmq.SUBSCRIBE, "")
+ sock.setsockopt(zmq.SUBSCRIBE, b"")
if poller is not None:
poller.register(sock, zmq.POLLIN)
return sock
diff --git a/selfdrive/orbd/.gitignore b/selfdrive/orbd/.gitignore
deleted file mode 100644
index 829780eb50..0000000000
--- a/selfdrive/orbd/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-orbd
-orbd_cpu
-test/turbocv_profile
-test/turbocv_test
-dspout/*
-dumb_test
-bilinear_lut.h
-orb_lut.h
diff --git a/selfdrive/orbd/Makefile b/selfdrive/orbd/Makefile
deleted file mode 100644
index c33a8636bc..0000000000
--- a/selfdrive/orbd/Makefile
+++ /dev/null
@@ -1,105 +0,0 @@
-# CPU
-
-CC = clang
-CXX = clang++
-
-WARN_FLAGS = -Werror=implicit-function-declaration \
- -Werror=incompatible-pointer-types \
- -Werror=int-conversion \
- -Werror=return-type \
- -Werror=format-extra-args
-
-JSON_FLAGS = -I$(PHONELIBS)/json/src
-
-CFLAGS = -std=gnu11 -g -O2 -fPIC $(WARN_FLAGS) -Iinclude $(JSON_FLAGS) -I.
-CXXFLAGS = -std=c++11 -g -O2 -fPIC $(WARN_FLAGS) -Iinclude $(JSON_FLAGS) -I.
-LDFLAGS =
-
-# profile
-# CXXFLAGS += -DTURBOCV_PROFILE=1
-
-PHONELIBS = ../../phonelibs
-BASEDIR = ../..
-EXTERNAL = ../../external
-PYTHONLIBS =
-
-UNAME_M := $(shell uname -m)
-
-ifeq ($(UNAME_M),x86_64)
-# computer
-
-ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include
-ZMQ_LIBS = -L$(BASEDIR)/external/zmq/lib/ \
- -l:libczmq.a -l:libzmq.a -lpthread
-
-OPENCV_LIBS = -lopencv_core -lopencv_highgui -lopencv_features2d -lopencv_imgproc
-
-CXXFLAGS += -fopenmp
-LDFLAGS += -lomp
-
-else
-# phone
-ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include
-ZMQ_LIBS = -L$(PHONELIBS)/zmq/aarch64/lib \
- -l:libczmq.a -l:libzmq.a \
- -lgnustl_shared
-
-OPENCV_FLAGS = -I$(PHONELIBS)/opencv/include
-OPENCV_LIBS = -Wl,--enable-new-dtags -Wl,-rpath,/usr/local/lib/python2.7/site-packages -L/usr/local/lib/python2.7/site-packages -l:cv2.so
-
-endif
-
-.PHONY: all
-all: orbd
-
-include ../common/cereal.mk
-
-DEP_OBJS = ../common/visionipc.o ../common/swaglog.o $(PHONELIBS)/json/src/json.o
-
-orbd: orbd_dsp.o $(DEP_OBJS) calculator_stub.o freethedsp.o
- @echo "[ LINK ] $@"
- $(CXX) -fPIC -o '$@' $^ \
- $(LDFLAGS) \
- $(ZMQ_LIBS) \
- $(CEREAL_LIBS) \
- -L/usr/lib \
- -L/system/vendor/lib64 \
- -ladsprpc \
- -lm -lz -llog
-
-%.o: %.c
- @echo "[ CC ] $@"
- $(CC) $(CFLAGS) \
- $(ZMQ_FLAGS) \
- -I../ \
- -I../../ \
- -c -o '$@' '$<'
-
-orbd_dsp.o: orbd.cc
- @echo "[ CXX ] $@"
- $(CXX) $(CXXFLAGS) \
- $(CEREAL_CXXFLAGS) \
- $(ZMQ_FLAGS) \
- $(OPENCV_FLAGS) \
- -DDSP \
- -I../ \
- -I../../ \
- -I../../../ \
- -I./include \
- -c -o '$@' '$<'
-
-freethedsp.o: dsp/freethedsp.c
- @echo "[ CC ] $@"
- $(CC) $(CFLAGS) \
- -c -o '$@' '$<'
-
-calculator_stub.o: dsp/gen/calculator_stub.c
- @echo "[ CC ] $@"
- $(CC) $(CFLAGS) -I./include -c -o '$@' '$<'
-
--include internal.mk
-
-.PHONY: clean
-clean:
- rm -f *.o turbocv.so orbd test/turbocv_profile test/turbocv_test test/*.o *_lut.h
-
diff --git a/selfdrive/orbd/dsp/freethedsp.c b/selfdrive/orbd/dsp/freethedsp.c
deleted file mode 100644
index 298f4fd831..0000000000
--- a/selfdrive/orbd/dsp/freethedsp.c
+++ /dev/null
@@ -1,119 +0,0 @@
-// freethedsp by geohot
-// (because the DSP should be free)
-// released under MIT License
-
-// usage instructions:
-// 1. Compile an example from the Qualcomm Hexagon SDK
-// 2. Try to run it on your phone
-// 3. Be very sad when "adsprpc ... dlopen error: ... signature verify start failed for ..." appears in logcat
-// ...here is where people would give up before freethedsp
-// 4. Compile freethedsp with 'clang -shared freethedsp.c -o freethedsp.so' (or statically link it to your program)
-// 5. Run your program with 'LD_PRELOAD=./freethedsp.so ./'
-// 6. OMG THE DSP WORKS
-// 7. Be happy.
-
-// *** patch may have to change for your phone ***
-
-// this is patching /dsp/fastrpc_shell_0
-// correct if sha hash of fastrpc_shell_0 is "fbadc96848aefad99a95aa4edb560929dcdf78f8"
-// patch to return 0xFFFFFFFF from is_test_enabled instead of 0
-// your fastrpc_shell_0 may vary
-#define PATCH_ADDR 0x5200c
-#define PATCH_OLD "\x40\x3f\x20\x50"
-#define PATCH_NEW "\x40\x3f\x00\x5a"
-#define PATCH_LEN (sizeof(PATCH_OLD)-1)
-#define _BITS_IOCTL_H_
-
-// under 100 lines of code begins now
-#include
-#include
-#include
-#include
-#include
-
-// ioctl stuff
-#define IOC_OUT 0x40000000 /* copy out parameters */
-#define IOC_IN 0x80000000 /* copy in parameters */
-#define IOC_INOUT (IOC_IN|IOC_OUT)
-#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
-
-#define _IOC(inout,group,num,len) \
- (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
-#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
-
-// ion ioctls
-#include
-#define ION_IOC_MSM_MAGIC 'M'
-#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \
- struct ion_flush_data)
-
-struct ion_flush_data {
- ion_user_handle_t handle;
- int fd;
- void *vaddr;
- unsigned int offset;
- unsigned int length;
-};
-
-// fastrpc ioctls
-#define FASTRPC_IOCTL_INIT _IOWR('R', 6, struct fastrpc_ioctl_init)
-
-struct fastrpc_ioctl_init {
- uint32_t flags; /* one of FASTRPC_INIT_* macros */
- uintptr_t __user file; /* pointer to elf file */
- int32_t filelen; /* elf file length */
- int32_t filefd; /* ION fd for the file */
- uintptr_t __user mem; /* mem for the PD */
- int32_t memlen; /* mem length */
- int32_t memfd; /* ION fd for the mem */
-};
-
-int ioctl(int fd, unsigned long request, void *arg) {
- static void *handle = NULL;
- static int (*orig_ioctl)(int, int, void*);
-
- if (handle == NULL) {
- handle = dlopen("/system/lib64/libc.so", RTLD_LAZY);
- assert(handle != NULL);
- orig_ioctl = dlsym(handle, "ioctl");
- }
-
- int ret = orig_ioctl(fd, request, arg);
-
- // carefully modify this one
- if (request == FASTRPC_IOCTL_INIT) {
- struct fastrpc_ioctl_init *init = (struct fastrpc_ioctl_init *)arg;
-
- // confirm patch is correct and do the patch
- assert(memcmp((void*)(init->mem+PATCH_ADDR), PATCH_OLD, PATCH_LEN) == 0);
- memcpy((void*)(init->mem+PATCH_ADDR), PATCH_NEW, PATCH_LEN);
-
- // flush cache
- int ionfd = open("/dev/ion", O_RDONLY);
- assert(ionfd > 0);
-
- struct ion_fd_data fd_data;
- fd_data.fd = init->memfd;
- int ret = ioctl(ionfd, ION_IOC_IMPORT, &fd_data);
- assert(ret == 0);
-
- struct ion_flush_data flush_data;
- flush_data.handle = fd_data.handle;
- flush_data.vaddr = (void*)init->mem;
- flush_data.offset = 0;
- flush_data.length = init->memlen;
- ret = ioctl(ionfd, ION_IOC_CLEAN_INV_CACHES, &flush_data);
- assert(ret == 0);
-
- struct ion_handle_data handle_data;
- handle_data.handle = fd_data.handle;
- ret = ioctl(ionfd, ION_IOC_FREE, &handle_data);
- assert(ret == 0);
-
- // cleanup
- close(ionfd);
- }
-
- return ret;
-}
-
diff --git a/selfdrive/orbd/dsp/gen/calculator.h b/selfdrive/orbd/dsp/gen/calculator.h
deleted file mode 100644
index 86a3de6717..0000000000
--- a/selfdrive/orbd/dsp/gen/calculator.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef _CALCULATOR_H
-#define _CALCULATOR_H
-
-#include
-typedef uint8_t uint8;
-typedef uint32_t uint32;
-
-#ifndef __QAIC_HEADER
-#define __QAIC_HEADER(ff) ff
-#endif //__QAIC_HEADER
-
-#ifndef __QAIC_HEADER_EXPORT
-#define __QAIC_HEADER_EXPORT
-#endif // __QAIC_HEADER_EXPORT
-
-#ifndef __QAIC_HEADER_ATTRIBUTE
-#define __QAIC_HEADER_ATTRIBUTE
-#endif // __QAIC_HEADER_ATTRIBUTE
-
-#ifndef __QAIC_IMPL
-#define __QAIC_IMPL(ff) ff
-#endif //__QAIC_IMPL
-
-#ifndef __QAIC_IMPL_EXPORT
-#define __QAIC_IMPL_EXPORT
-#endif // __QAIC_IMPL_EXPORT
-
-#ifndef __QAIC_IMPL_ATTRIBUTE
-#define __QAIC_IMPL_ATTRIBUTE
-#endif // __QAIC_IMPL_ATTRIBUTE
-#ifdef __cplusplus
-extern "C" {
-#endif
-__QAIC_HEADER_EXPORT int __QAIC_HEADER(calculator_init)(uint32* leet) __QAIC_HEADER_ATTRIBUTE;
-__QAIC_HEADER_EXPORT int __QAIC_HEADER(calculator_extract_and_match)(const uint8* img, int imgLen, uint8* features, int featuresLen) __QAIC_HEADER_ATTRIBUTE;
-#ifdef __cplusplus
-}
-#endif
-#endif //_CALCULATOR_H
diff --git a/selfdrive/orbd/dsp/gen/calculator_stub.c b/selfdrive/orbd/dsp/gen/calculator_stub.c
deleted file mode 100644
index 66e4a0f822..0000000000
--- a/selfdrive/orbd/dsp/gen/calculator_stub.c
+++ /dev/null
@@ -1,613 +0,0 @@
-#ifndef _CALCULATOR_STUB_H
-#define _CALCULATOR_STUB_H
-#include "calculator.h"
-
-// remote.h
-#include
-#include
-
-typedef uint32_t remote_handle;
-typedef uint64_t remote_handle64;
-
-typedef struct {
- void *pv;
- size_t nLen;
-} remote_buf;
-
-typedef struct {
- int32_t fd;
- uint32_t offset;
-} remote_dma_handle;
-
-typedef union {
- remote_buf buf;
- remote_handle h;
- remote_handle64 h64;
- remote_dma_handle dma;
-} remote_arg;
-
-int remote_handle_open(const char* name, remote_handle *ph);
-int remote_handle_invoke(remote_handle h, uint32_t dwScalars, remote_arg *pra);
-int remote_handle_close(remote_handle h);
-
-#define REMOTE_SCALARS_MAKEX(nAttr,nMethod,nIn,nOut,noIn,noOut) \
- ((((uint32_t) (nAttr) & 0x7) << 29) | \
- (((uint32_t) (nMethod) & 0x1f) << 24) | \
- (((uint32_t) (nIn) & 0xff) << 16) | \
- (((uint32_t) (nOut) & 0xff) << 8) | \
- (((uint32_t) (noIn) & 0x0f) << 4) | \
- ((uint32_t) (noOut) & 0x0f))
-
-#ifndef _QAIC_ENV_H
-#define _QAIC_ENV_H
-
-#ifdef __GNUC__
-#ifdef __clang__
-#pragma GCC diagnostic ignored "-Wunknown-pragmas"
-#else
-#pragma GCC diagnostic ignored "-Wpragmas"
-#endif
-#pragma GCC diagnostic ignored "-Wuninitialized"
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
-#ifndef _ATTRIBUTE_UNUSED
-
-#ifdef _WIN32
-#define _ATTRIBUTE_UNUSED
-#else
-#define _ATTRIBUTE_UNUSED __attribute__ ((unused))
-#endif
-
-#endif // _ATTRIBUTE_UNUSED
-
-#ifndef __QAIC_REMOTE
-#define __QAIC_REMOTE(ff) ff
-#endif //__QAIC_REMOTE
-
-#ifndef __QAIC_HEADER
-#define __QAIC_HEADER(ff) ff
-#endif //__QAIC_HEADER
-
-#ifndef __QAIC_HEADER_EXPORT
-#define __QAIC_HEADER_EXPORT
-#endif // __QAIC_HEADER_EXPORT
-
-#ifndef __QAIC_HEADER_ATTRIBUTE
-#define __QAIC_HEADER_ATTRIBUTE
-#endif // __QAIC_HEADER_ATTRIBUTE
-
-#ifndef __QAIC_IMPL
-#define __QAIC_IMPL(ff) ff
-#endif //__QAIC_IMPL
-
-#ifndef __QAIC_IMPL_EXPORT
-#define __QAIC_IMPL_EXPORT
-#endif // __QAIC_IMPL_EXPORT
-
-#ifndef __QAIC_IMPL_ATTRIBUTE
-#define __QAIC_IMPL_ATTRIBUTE
-#endif // __QAIC_IMPL_ATTRIBUTE
-
-#ifndef __QAIC_STUB
-#define __QAIC_STUB(ff) ff
-#endif //__QAIC_STUB
-
-#ifndef __QAIC_STUB_EXPORT
-#define __QAIC_STUB_EXPORT
-#endif // __QAIC_STUB_EXPORT
-
-#ifndef __QAIC_STUB_ATTRIBUTE
-#define __QAIC_STUB_ATTRIBUTE
-#endif // __QAIC_STUB_ATTRIBUTE
-
-#ifndef __QAIC_SKEL
-#define __QAIC_SKEL(ff) ff
-#endif //__QAIC_SKEL__
-
-#ifndef __QAIC_SKEL_EXPORT
-#define __QAIC_SKEL_EXPORT
-#endif // __QAIC_SKEL_EXPORT
-
-#ifndef __QAIC_SKEL_ATTRIBUTE
-#define __QAIC_SKEL_ATTRIBUTE
-#endif // __QAIC_SKEL_ATTRIBUTE
-
-#ifdef __QAIC_DEBUG__
- #ifndef __QAIC_DBG_PRINTF__
- #include
- #define __QAIC_DBG_PRINTF__( ee ) do { printf ee ; } while(0)
- #endif
-#else
- #define __QAIC_DBG_PRINTF__( ee ) (void)0
-#endif
-
-
-#define _OFFSET(src, sof) ((void*)(((char*)(src)) + (sof)))
-
-#define _COPY(dst, dof, src, sof, sz) \
- do {\
- struct __copy { \
- char ar[sz]; \
- };\
- *(struct __copy*)_OFFSET(dst, dof) = *(struct __copy*)_OFFSET(src, sof);\
- } while (0)
-
-#define _COPYIF(dst, dof, src, sof, sz) \
- do {\
- if(_OFFSET(dst, dof) != _OFFSET(src, sof)) {\
- _COPY(dst, dof, src, sof, sz); \
- } \
- } while (0)
-
-_ATTRIBUTE_UNUSED
-static __inline void _qaic_memmove(void* dst, void* src, int size) {
- int i;
- for(i = 0; i < size; ++i) {
- ((char*)dst)[i] = ((char*)src)[i];
- }
-}
-
-#define _MEMMOVEIF(dst, src, sz) \
- do {\
- if(dst != src) {\
- _qaic_memmove(dst, src, sz);\
- } \
- } while (0)
-
-
-#define _ASSIGN(dst, src, sof) \
- do {\
- dst = OFFSET(src, sof); \
- } while (0)
-
-#define _STD_STRLEN_IF(str) (str == 0 ? 0 : strlen(str))
-
-#define AEE_SUCCESS 0
-#define AEE_EOFFSET 0x80000400
-#define AEE_EBADPARM (AEE_EOFFSET + 0x00E)
-
-#define _TRY(ee, func) \
- do { \
- if (AEE_SUCCESS != ((ee) = func)) {\
- __QAIC_DBG_PRINTF__((__FILE__ ":%d:error:%d:%s\n", __LINE__, (int)(ee),#func));\
- goto ee##bail;\
- } \
- } while (0)
-
-#define _CATCH(exception) exception##bail: if (exception != AEE_SUCCESS)
-
-#define _ASSERT(nErr, ff) _TRY(nErr, 0 == (ff) ? AEE_EBADPARM : AEE_SUCCESS)
-
-#ifdef __QAIC_DEBUG__
-#define _ALLOCATE(nErr, pal, size, alignment, pv) _TRY(nErr, _allocator_alloc(pal, __FILE_LINE__, size, alignment, (void**)&pv))
-#else
-#define _ALLOCATE(nErr, pal, size, alignment, pv) _TRY(nErr, _allocator_alloc(pal, 0, size, alignment, (void**)&pv))
-#endif
-
-
-#endif // _QAIC_ENV_H
-
-#ifndef _ALLOCATOR_H
-#define _ALLOCATOR_H
-
-#include
-#include
-
-typedef struct _heap _heap;
-struct _heap {
- _heap* pPrev;
- const char* loc;
- uint64_t buf;
-};
-
-typedef struct _allocator {
- _heap* pheap;
- uint8_t* stack;
- uint8_t* stackEnd;
- int nSize;
-} _allocator;
-
-_ATTRIBUTE_UNUSED
-static __inline int _heap_alloc(_heap** ppa, const char* loc, int size, void** ppbuf) {
- _heap* pn = 0;
- pn = malloc(size + sizeof(_heap) - sizeof(uint64_t));
- if(pn != 0) {
- pn->pPrev = *ppa;
- pn->loc = loc;
- *ppa = pn;
- *ppbuf = (void*)&(pn->buf);
- return 0;
- } else {
- return -1;
- }
-}
-#define _ALIGN_SIZE(x, y) (((x) + (y-1)) & ~(y-1))
-
-_ATTRIBUTE_UNUSED
-static __inline int _allocator_alloc(_allocator* me,
- const char* loc,
- int size,
- unsigned int al,
- void** ppbuf) {
- if(size < 0) {
- return -1;
- } else if (size == 0) {
- *ppbuf = 0;
- return 0;
- }
- if((_ALIGN_SIZE((uintptr_t)me->stackEnd, al) + size) < (uintptr_t)me->stack + me->nSize) {
- *ppbuf = (uint8_t*)_ALIGN_SIZE((uintptr_t)me->stackEnd, al);
- me->stackEnd = (uint8_t*)_ALIGN_SIZE((uintptr_t)me->stackEnd, al) + size;
- return 0;
- } else {
- return _heap_alloc(&me->pheap, loc, size, ppbuf);
- }
-}
-
-_ATTRIBUTE_UNUSED
-static __inline void _allocator_deinit(_allocator* me) {
- _heap* pa = me->pheap;
- while(pa != 0) {
- _heap* pn = pa;
- const char* loc = pn->loc;
- (void)loc;
- pa = pn->pPrev;
- free(pn);
- }
-}
-
-_ATTRIBUTE_UNUSED
-static __inline void _allocator_init(_allocator* me, uint8_t* stack, int stackSize) {
- me->stack = stack;
- me->stackEnd = stack + stackSize;
- me->nSize = stackSize;
- me->pheap = 0;
-}
-
-
-#endif // _ALLOCATOR_H
-
-#ifndef SLIM_H
-#define SLIM_H
-
-#include
-
-//a C data structure for the idl types that can be used to implement
-//static and dynamic language bindings fairly efficiently.
-//
-//the goal is to have a minimal ROM and RAM footprint and without
-//doing too many allocations. A good way to package these things seemed
-//like the module boundary, so all the idls within one module can share
-//all the type references.
-
-
-#define PARAMETER_IN 0x0
-#define PARAMETER_OUT 0x1
-#define PARAMETER_INOUT 0x2
-#define PARAMETER_ROUT 0x3
-#define PARAMETER_INROUT 0x4
-
-//the types that we get from idl
-#define TYPE_OBJECT 0x0
-#define TYPE_INTERFACE 0x1
-#define TYPE_PRIMITIVE 0x2
-#define TYPE_ENUM 0x3
-#define TYPE_STRING 0x4
-#define TYPE_WSTRING 0x5
-#define TYPE_STRUCTURE 0x6
-#define TYPE_UNION 0x7
-#define TYPE_ARRAY 0x8
-#define TYPE_SEQUENCE 0x9
-
-//these require the pack/unpack to recurse
-//so it's a hint to those languages that can optimize in cases where
-//recursion isn't necessary.
-#define TYPE_COMPLEX_STRUCTURE (0x10 | TYPE_STRUCTURE)
-#define TYPE_COMPLEX_UNION (0x10 | TYPE_UNION)
-#define TYPE_COMPLEX_ARRAY (0x10 | TYPE_ARRAY)
-#define TYPE_COMPLEX_SEQUENCE (0x10 | TYPE_SEQUENCE)
-
-
-typedef struct Type Type;
-
-#define INHERIT_TYPE\
- int32_t nativeSize; /*in the simple case its the same as wire size and alignment*/\
- union {\
- struct {\
- const uintptr_t p1;\
- const uintptr_t p2;\
- } _cast;\
- struct {\
- uint32_t iid;\
- uint32_t bNotNil;\
- } object;\
- struct {\
- const Type *arrayType;\
- int32_t nItems;\
- } array;\
- struct {\
- const Type *seqType;\
- int32_t nMaxLen;\
- } seqSimple; \
- struct {\
- uint32_t bFloating;\
- uint32_t bSigned;\
- } prim; \
- const SequenceType* seqComplex;\
- const UnionType *unionType;\
- const StructType *structType;\
- int32_t stringMaxLen;\
- uint8_t bInterfaceNotNil;\
- } param;\
- uint8_t type;\
- uint8_t nativeAlignment\
-
-typedef struct UnionType UnionType;
-typedef struct StructType StructType;
-typedef struct SequenceType SequenceType;
-struct Type {
- INHERIT_TYPE;
-};
-
-struct SequenceType {
- const Type * seqType;
- uint32_t nMaxLen;
- uint32_t inSize;
- uint32_t routSizePrimIn;
- uint32_t routSizePrimROut;
-};
-
-//byte offset from the start of the case values for
-//this unions case value array. it MUST be aligned
-//at the alignment requrements for the descriptor
-//
-//if negative it means that the unions cases are
-//simple enumerators, so the value read from the descriptor
-//can be used directly to find the correct case
-typedef union CaseValuePtr CaseValuePtr;
-union CaseValuePtr {
- const uint8_t* value8s;
- const uint16_t* value16s;
- const uint32_t* value32s;
- const uint64_t* value64s;
-};
-
-//these are only used in complex cases
-//so I pulled them out of the type definition as references to make
-//the type smaller
-struct UnionType {
- const Type *descriptor;
- uint32_t nCases;
- const CaseValuePtr caseValues;
- const Type * const *cases;
- int32_t inSize;
- int32_t routSizePrimIn;
- int32_t routSizePrimROut;
- uint8_t inAlignment;
- uint8_t routAlignmentPrimIn;
- uint8_t routAlignmentPrimROut;
- uint8_t inCaseAlignment;
- uint8_t routCaseAlignmentPrimIn;
- uint8_t routCaseAlignmentPrimROut;
- uint8_t nativeCaseAlignment;
- uint8_t bDefaultCase;
-};
-
-struct StructType {
- uint32_t nMembers;
- const Type * const *members;
- int32_t inSize;
- int32_t routSizePrimIn;
- int32_t routSizePrimROut;
- uint8_t inAlignment;
- uint8_t routAlignmentPrimIn;
- uint8_t routAlignmentPrimROut;
-};
-
-typedef struct Parameter Parameter;
-struct Parameter {
- INHERIT_TYPE;
- uint8_t mode;
- uint8_t bNotNil;
-};
-
-#define SLIM_IFPTR32(is32,is64) (sizeof(uintptr_t) == 4 ? (is32) : (is64))
-#define SLIM_SCALARS_IS_DYNAMIC(u) (((u) & 0x00ffffff) == 0x00ffffff)
-
-typedef struct Method Method;
-struct Method {
- uint32_t uScalars; //no method index
- int32_t primInSize;
- int32_t primROutSize;
- int maxArgs;
- int numParams;
- const Parameter * const *params;
- uint8_t primInAlignment;
- uint8_t primROutAlignment;
-};
-
-typedef struct Interface Interface;
-
-struct Interface {
- int nMethods;
- const Method * const *methodArray;
- int nIIds;
- const uint32_t *iids;
- const uint16_t* methodStringArray;
- const uint16_t* methodStrings;
- const char* strings;
-};
-
-
-#endif //SLIM_H
-
-
-#ifndef _CALCULATOR_SLIM_H
-#define _CALCULATOR_SLIM_H
-
-// remote.h
-
-#include
-
-#ifndef __QAIC_SLIM
-#define __QAIC_SLIM(ff) ff
-#endif
-#ifndef __QAIC_SLIM_EXPORT
-#define __QAIC_SLIM_EXPORT
-#endif
-
-static const Type types[1];
-static const Type types[1] = {{0x1,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x1}};
-static const Parameter parameters[3] = {{0x4,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x4,3,0},{SLIM_IFPTR32(0x8,0x10),{{(const uintptr_t)&(types[0]),(const uintptr_t)0x0}}, 9,SLIM_IFPTR32(0x4,0x8),0,0},{SLIM_IFPTR32(0x8,0x10),{{(const uintptr_t)&(types[0]),(const uintptr_t)0x0}}, 9,SLIM_IFPTR32(0x4,0x8),3,0}};
-static const Parameter* const parameterArrays[3] = {(&(parameters[1])),(&(parameters[2])),(&(parameters[0]))};
-static const Method methods[2] = {{REMOTE_SCALARS_MAKEX(0,0,0x0,0x1,0x0,0x0),0x0,0x4,1,1,(&(parameterArrays[2])),0x1,0x4},{REMOTE_SCALARS_MAKEX(0,0,0x2,0x1,0x0,0x0),0x8,0x0,5,2,(&(parameterArrays[0])),0x4,0x1}};
-static const Method* const methodArrays[2] = {&(methods[0]),&(methods[1])};
-static const char strings[41] = "extract_and_match\0features\0leet\0init\0img\0";
-static const uint16_t methodStrings[5] = {0,37,18,32,27};
-static const uint16_t methodStringsArrays[2] = {3,0};
-__QAIC_SLIM_EXPORT const Interface __QAIC_SLIM(calculator_slim) = {2,&(methodArrays[0]),0,0,&(methodStringsArrays [0]),methodStrings,strings};
-#endif //_CALCULATOR_SLIM_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _const_calculator_handle
-#define _const_calculator_handle ((remote_handle)-1)
-#endif //_const_calculator_handle
-
-static void _calculator_pls_dtor(void* data) {
- remote_handle* ph = (remote_handle*)data;
- if(_const_calculator_handle != *ph) {
- (void)__QAIC_REMOTE(remote_handle_close)(*ph);
- *ph = _const_calculator_handle;
- }
-}
-
-static int _calculator_pls_ctor(void* ctx, void* data) {
- remote_handle* ph = (remote_handle*)data;
- *ph = _const_calculator_handle;
- if(*ph == (remote_handle)-1) {
- return __QAIC_REMOTE(remote_handle_open)((const char*)ctx, ph);
- }
- return 0;
-}
-
-#if (defined __qdsp6__) || (defined __hexagon__)
-#pragma weak adsp_pls_add_lookup
-extern int adsp_pls_add_lookup(uint32_t type, uint32_t key, int size, int (*ctor)(void* ctx, void* data), void* ctx, void (*dtor)(void* ctx), void** ppo);
-#pragma weak HAP_pls_add_lookup
-extern int HAP_pls_add_lookup(uint32_t type, uint32_t key, int size, int (*ctor)(void* ctx, void* data), void* ctx, void (*dtor)(void* ctx), void** ppo);
-
-__QAIC_STUB_EXPORT remote_handle _calculator_handle(void) {
- remote_handle* ph;
- if(adsp_pls_add_lookup) {
- if(0 == adsp_pls_add_lookup((uint32_t)_calculator_handle, 0, sizeof(*ph), _calculator_pls_ctor, "calculator", _calculator_pls_dtor, (void**)&ph)) {
- return *ph;
- }
- return (remote_handle)-1;
- } else if(HAP_pls_add_lookup) {
- if(0 == HAP_pls_add_lookup((uint32_t)_calculator_handle, 0, sizeof(*ph), _calculator_pls_ctor, "calculator", _calculator_pls_dtor, (void**)&ph)) {
- return *ph;
- }
- return (remote_handle)-1;
- }
- return(remote_handle)-1;
-}
-
-#else //__qdsp6__ || __hexagon__
-
-uint32_t _calculator_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare);
-
-#ifdef _WIN32
-#include "Windows.h"
-uint32_t _calculator_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare) {
- return (uint32_t)InterlockedCompareExchange((volatile LONG*)puDest, (LONG)uExchange, (LONG)uCompare);
-}
-#elif __GNUC__
-uint32_t _calculator_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare) {
- return __sync_val_compare_and_swap(puDest, uCompare, uExchange);
-}
-#endif //_WIN32
-
-
-__QAIC_STUB_EXPORT remote_handle _calculator_handle(void) {
- static remote_handle handle = _const_calculator_handle;
- if((remote_handle)-1 != handle) {
- return handle;
- } else {
- remote_handle tmp;
- int nErr = _calculator_pls_ctor("calculator", (void*)&tmp);
- if(nErr) {
- return (remote_handle)-1;
- }
- if(((remote_handle)-1 != handle) || ((remote_handle)-1 != (remote_handle)_calculator_atomic_CompareAndExchange((uint32_t*)&handle, (uint32_t)tmp, (uint32_t)-1))) {
- _calculator_pls_dtor(&tmp);
- }
- return handle;
- }
-}
-
-#endif //__qdsp6__
-
-__QAIC_STUB_EXPORT int __QAIC_STUB(calculator_skel_invoke)(uint32_t _sc, remote_arg* _pra) __QAIC_STUB_ATTRIBUTE {
- return __QAIC_REMOTE(remote_handle_invoke)(_calculator_handle(), _sc, _pra);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern int remote_register_dma_handle(int, uint32_t);
-static __inline int _stub_method(remote_handle _handle, uint32_t _mid, uint32_t _rout0[1]) {
- int _numIn[1];
- remote_arg _pra[1];
- uint32_t _primROut[1];
- int _nErr = 0;
- _numIn[0] = 0;
- _pra[(_numIn[0] + 0)].buf.pv = (void*)_primROut;
- _pra[(_numIn[0] + 0)].buf.nLen = sizeof(_primROut);
- _TRY(_nErr, __QAIC_REMOTE(remote_handle_invoke)(_handle, REMOTE_SCALARS_MAKEX(0, _mid, 0, 1, 0, 0), _pra));
- _COPY(_rout0, 0, _primROut, 0, 4);
- _CATCH(_nErr) {}
- return _nErr;
-}
-__QAIC_STUB_EXPORT int __QAIC_STUB(calculator_init)(uint32* leet) __QAIC_STUB_ATTRIBUTE {
- uint32_t _mid = 0;
- return _stub_method(_calculator_handle(), _mid, (uint32_t*)leet);
-}
-static __inline int _stub_method_1(remote_handle _handle, uint32_t _mid, char* _in0[1], uint32_t _in0Len[1], char* _rout1[1], uint32_t _rout1Len[1]) {
- int _numIn[1];
- remote_arg _pra[3];
- uint32_t _primIn[2];
- remote_arg* _praIn;
- remote_arg* _praROut;
- int _nErr = 0;
- _numIn[0] = 1;
- _pra[0].buf.pv = (void*)_primIn;
- _pra[0].buf.nLen = sizeof(_primIn);
- _COPY(_primIn, 0, _in0Len, 0, 4);
- _praIn = (_pra + 1);
- _praIn[0].buf.pv = _in0[0];
- _praIn[0].buf.nLen = (1 * _in0Len[0]);
- _COPY(_primIn, 4, _rout1Len, 0, 4);
- _praROut = (_praIn + _numIn[0] + 0);
- _praROut[0].buf.pv = _rout1[0];
- _praROut[0].buf.nLen = (1 * _rout1Len[0]);
- _TRY(_nErr, __QAIC_REMOTE(remote_handle_invoke)(_handle, REMOTE_SCALARS_MAKEX(0, _mid, 2, 1, 0, 0), _pra));
- _CATCH(_nErr) {}
- return _nErr;
-}
-__QAIC_STUB_EXPORT int __QAIC_STUB(calculator_extract_and_match)(const uint8* img, int imgLen, uint8* features, int featuresLen) __QAIC_STUB_ATTRIBUTE {
- uint32_t _mid = 1;
- return _stub_method_1(_calculator_handle(), _mid, (char**)&img, (uint32_t*)&imgLen, (char**)&features, (uint32_t*)&featuresLen);
-}
-#ifdef __cplusplus
-}
-#endif
-#endif //_CALCULATOR_STUB_H
diff --git a/selfdrive/orbd/dsp/gen/libcalculator_skel.so b/selfdrive/orbd/dsp/gen/libcalculator_skel.so
deleted file mode 100755
index e48cab4820..0000000000
Binary files a/selfdrive/orbd/dsp/gen/libcalculator_skel.so and /dev/null differ
diff --git a/selfdrive/orbd/extractor.h b/selfdrive/orbd/extractor.h
deleted file mode 100644
index c6392d446b..0000000000
--- a/selfdrive/orbd/extractor.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef EXTRACTOR_H
-#define EXTRACTOR_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-
-#define ORBD_KEYPOINTS 3000
-#define ORBD_DESCRIPTOR_LENGTH 32
-#define ORBD_HEIGHT 874
-#define ORBD_WIDTH 1164
-
-// matches OrbFeatures from log.capnp
-struct orb_features {
- // align this
- uint16_t n_corners;
- uint16_t xy[ORBD_KEYPOINTS][2];
- uint8_t octave[ORBD_KEYPOINTS];
- uint8_t des[ORBD_KEYPOINTS][ORBD_DESCRIPTOR_LENGTH];
- int16_t matches[ORBD_KEYPOINTS];
-};
-
-// forward declare this
-struct pyramid;
-
-// manage the pyramids in extractor.c
-void init_gpyrs();
-int extract_and_match_gpyrs(const uint8_t *img, struct orb_features *);
-int extract_and_match(const uint8_t *img, struct pyramid *pyrs, struct pyramid *prev_pyrs, struct orb_features *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // EXTRACTOR_H
diff --git a/selfdrive/orbd/orbd.cc b/selfdrive/orbd/orbd.cc
deleted file mode 100644
index 26c9ffec76..0000000000
--- a/selfdrive/orbd/orbd.cc
+++ /dev/null
@@ -1,181 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "common/visionipc.h"
-#include "common/swaglog.h"
-
-#include "extractor.h"
-
-#ifdef DSP
-#include "dsp/gen/calculator.h"
-#else
-#include "turbocv.h"
-#endif
-
-#include
-#include
-#include "cereal/gen/cpp/log.capnp.h"
-
-#ifndef PATH_MAX
-#include
-#endif
-
-volatile int do_exit = 0;
-
-static void set_do_exit(int sig) {
- do_exit = 1;
-}
-
-int main(int argc, char *argv[]) {
- int err;
- setpriority(PRIO_PROCESS, 0, -13);
- printf("starting orbd\n");
-
-#ifdef DSP
- uint32_t test_leet = 0;
- char my_path[PATH_MAX+1];
- memset(my_path, 0, sizeof(my_path));
-
- ssize_t len = readlink("/proc/self/exe", my_path, sizeof(my_path));
- assert(len > 5);
- my_path[len-5] = '\0';
- LOGW("running from %s with PATH_MAX %d", my_path, PATH_MAX);
-
- char adsp_path[PATH_MAX+1];
- snprintf(adsp_path, PATH_MAX, "ADSP_LIBRARY_PATH=%s/dsp/gen", my_path);
- assert(putenv(adsp_path) == 0);
-
- assert(calculator_init(&test_leet) == 0);
- assert(test_leet == 0x1337);
- LOGW("orbd init complete");
-#else
- init_gpyrs();
-#endif
-
- signal(SIGINT, (sighandler_t) set_do_exit);
- signal(SIGTERM, (sighandler_t) set_do_exit);
-
- void *ctx = zmq_ctx_new();
-
- void *orb_features_sock = zmq_socket(ctx, ZMQ_PUB);
- assert(orb_features_sock);
- zmq_bind(orb_features_sock, "tcp://*:8058");
-
- void *orb_features_summary_sock = zmq_socket(ctx, ZMQ_PUB);
- assert(orb_features_summary_sock);
- zmq_bind(orb_features_summary_sock, "tcp://*:8062");
-
- struct orb_features *features = (struct orb_features *)malloc(sizeof(struct orb_features));
- int last_frame_id = 0;
-
- VisionStream stream;
- while (!do_exit) {
- VisionStreamBufs buf_info;
- err = visionstream_init(&stream, VISION_STREAM_YUV, true, &buf_info);
- if (err) {
- printf("visionstream connect fail\n");
- usleep(100000);
- continue;
- }
- uint64_t timestamp_last_eof = 0;
- while (!do_exit) {
- VIPCBuf *buf;
- VIPCBufExtra extra;
- buf = visionstream_get(&stream, &extra);
- if (buf == NULL) {
- printf("visionstream get failed\n");
- break;
- }
-
- uint64_t start = nanos_since_boot();
-#ifdef DSP
- int ret = calculator_extract_and_match((uint8_t *)buf->addr, ORBD_HEIGHT*ORBD_WIDTH, (uint8_t *)features, sizeof(struct orb_features));
-#else
- int ret = extract_and_match_gpyrs((uint8_t *) buf->addr, features);
-#endif
- uint64_t end = nanos_since_boot();
- LOGD("total(%d): %6.2f ms to get %4d features on %d", ret, (end-start)/1000000.0, features->n_corners, extra.frame_id);
- assert(ret == 0);
-
- if (last_frame_id+1 != extra.frame_id) {
- LOGW("dropped frame!");
- }
-
- last_frame_id = extra.frame_id;
-
- if (timestamp_last_eof == 0) {
- timestamp_last_eof = extra.timestamp_eof;
- continue;
- }
-
- int match_count = 0;
-
- // *** send OrbFeatures ***
- {
- // create capnp message
- capnp::MallocMessageBuilder msg;
- cereal::Event::Builder event = msg.initRoot();
- event.setLogMonoTime(nanos_since_boot());
-
- auto orb_features = event.initOrbFeatures();
-
- // set timestamps
- orb_features.setTimestampEof(extra.timestamp_eof);
- orb_features.setTimestampLastEof(timestamp_last_eof);
-
- // init descriptors for send
- kj::ArrayPtr descriptorsPtr = kj::arrayPtr((uint8_t *)features->des, ORBD_DESCRIPTOR_LENGTH * features->n_corners);
- orb_features.setDescriptors(descriptorsPtr);
-
- auto xs = orb_features.initXs(features->n_corners);
- auto ys = orb_features.initYs(features->n_corners);
- auto octaves = orb_features.initOctaves(features->n_corners);
- auto matches = orb_features.initMatches(features->n_corners);
-
- // copy out normalized keypoints
- for (int i = 0; i < features->n_corners; i++) {
- xs.set(i, features->xy[i][0] * 1.0f / ORBD_WIDTH - 0.5f);
- ys.set(i, features->xy[i][1] * 1.0f / ORBD_HEIGHT - 0.5f);
- octaves.set(i, features->octave[i]);
- matches.set(i, features->matches[i]);
- match_count += features->matches[i] != -1;
- }
-
- auto words = capnp::messageToFlatArray(msg);
- auto bytes = words.asBytes();
- zmq_send(orb_features_sock, bytes.begin(), bytes.size(), 0);
- }
-
- // *** send OrbFeaturesSummary ***
-
- {
- // create capnp message
- capnp::MallocMessageBuilder msg;
- cereal::Event::Builder event = msg.initRoot();
- event.setLogMonoTime(nanos_since_boot());
-
- auto orb_features_summary = event.initOrbFeaturesSummary();
-
- orb_features_summary.setTimestampEof(extra.timestamp_eof);
- orb_features_summary.setTimestampLastEof(timestamp_last_eof);
- orb_features_summary.setFeatureCount(features->n_corners);
- orb_features_summary.setMatchCount(match_count);
- orb_features_summary.setComputeNs(end-start);
-
- auto words = capnp::messageToFlatArray(msg);
- auto bytes = words.asBytes();
- zmq_send(orb_features_summary_sock, bytes.begin(), bytes.size(), 0);
- }
-
- timestamp_last_eof = extra.timestamp_eof;
- }
- }
- visionstream_destroy(&stream);
- return 0;
-}
-
diff --git a/selfdrive/pandad.py b/selfdrive/pandad.py
index 7f05a078c9..981546ccf9 100644
--- a/selfdrive/pandad.py
+++ b/selfdrive/pandad.py
@@ -10,4 +10,5 @@ def main(gctx=None):
os.execvp("./boardd", ["./boardd"])
if __name__ == "__main__":
- main()
+ main()
+
diff --git a/selfdrive/registration.py b/selfdrive/registration.py
index ed22e5dfa5..4327ed3a87 100644
--- a/selfdrive/registration.py
+++ b/selfdrive/registration.py
@@ -47,5 +47,5 @@ def register():
return None
if __name__ == "__main__":
- print api_get("").text
- print register()
+ print(api_get("").text)
+ print(register())
diff --git a/selfdrive/sensord/gpsd b/selfdrive/sensord/gpsd
index e55e2e59a5..20e5332795 100755
Binary files a/selfdrive/sensord/gpsd and b/selfdrive/sensord/gpsd differ
diff --git a/selfdrive/sensord/sensord b/selfdrive/sensord/sensord
index 476e9b101a..58f9d233c7 100755
Binary files a/selfdrive/sensord/sensord and b/selfdrive/sensord/sensord differ
diff --git a/selfdrive/service_list.yaml b/selfdrive/service_list.yaml
index 4195ee7b54..ae2351f581 100644
--- a/selfdrive/service_list.yaml
+++ b/selfdrive/service_list.yaml
@@ -69,6 +69,7 @@ orbKeyFrame: [8059, true]
uiLayoutState: [8060, true]
frontEncodeIdx: [8061, true]
orbFeaturesSummary: [8062, true]
+driverMonitoring: [8063, true]
testModel: [8040, false]
testLiveLocation: [8045, false]
diff --git a/selfdrive/services.py b/selfdrive/services.py
index d705cd808a..bd804afe79 100644
--- a/selfdrive/services.py
+++ b/selfdrive/services.py
@@ -10,5 +10,5 @@ service_list_path = os.path.join(os.path.dirname(__file__), "service_list.yaml")
service_list = {}
with open(service_list_path, "r") as f:
- for k, v in yaml.load(f).iteritems():
+ for k, v in yaml.load(f).items():
service_list[k] = Service(v[0], v[1])
diff --git a/selfdrive/test/plant/plant.py b/selfdrive/test/plant/plant.py
index 8ff062e02a..6c3eb66555 100755
--- a/selfdrive/test/plant/plant.py
+++ b/selfdrive/test/plant/plant.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import os
import struct
-
+from collections import namedtuple
import zmq
import numpy as np
@@ -210,15 +210,47 @@ class Plant(object):
print "%6.2f m %6.2f m/s %6.2f m/s2 %.2f ang gas: %.2f brake: %.2f steer: %5.2f lead_rel: %6.2f m %6.2f m/s" % (distance, speed, acceleration, self.angle_steer, gas, brake, steer_torque, d_rel, v_rel)
# ******** publish the car ********
- # TODO: the order is this list should not matter, but currently everytime we change carstate we break this test. Fix it!
- vls = [self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed),
- self.angle_steer, self.angle_steer_rate, 0,
+ vls_tuple = namedtuple('vls', [
+ 'XMISSION_SPEED',
+ 'WHEEL_SPEED_FL', 'WHEEL_SPEED_FR', 'WHEEL_SPEED_RL', 'WHEEL_SPEED_RR',
+ 'STEER_ANGLE', 'STEER_ANGLE_RATE', 'STEER_TORQUE_SENSOR',
+ 'LEFT_BLINKER', 'RIGHT_BLINKER',
+ 'GEAR',
+ 'WHEELS_MOVING',
+ 'BRAKE_ERROR_1', 'BRAKE_ERROR_2',
+ 'SEATBELT_DRIVER_LAMP', 'SEATBELT_DRIVER_LATCHED',
+ 'BRAKE_PRESSED', 'BRAKE_SWITCH',
+ 'CRUISE_BUTTONS',
+ 'ESP_DISABLED',
+ 'HUD_LEAD',
+ 'USER_BRAKE',
+ 'STEER_STATUS',
+ 'GEAR_SHIFTER',
+ 'PEDAL_GAS',
+ 'CRUISE_SETTING',
+ 'ACC_STATUS',
+
+ 'CRUISE_SPEED_PCM',
+ 'CRUISE_SPEED_OFFSET',
+
+ 'DOOR_OPEN_FL', 'DOOR_OPEN_FR', 'DOOR_OPEN_RL', 'DOOR_OPEN_RR',
+
+ 'CAR_GAS',
+ 'MAIN_ON',
+ 'EPB_STATE',
+ 'BRAKE_HOLD_ACTIVE',
+ 'INTERCEPTOR_GAS',
+ ])
+ vls = vls_tuple(
+ self.speed_sensor(speed),
+ self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed),
+ self.angle_steer, self.angle_steer_rate, 0, #Steer torque sensor
0, 0, # Blinkers
self.gear_choice,
speed != 0,
self.brake_error, self.brake_error,
not self.seatbelt, self.seatbelt, # Seatbelt
- self.brake_pressed, 0.,
+ self.brake_pressed, 0., #Brake pressed, Brake switch
cruise_buttons,
self.esp_disabled,
0, # HUD lead
@@ -238,11 +270,8 @@ class Plant(object):
self.main_on,
0, # EPB State
0, # Brake hold
- 0, # Interceptor feedback
- # 0,
-
-
- ]
+ 0 # Interceptor feedback
+ )
# TODO: publish each message at proper frequency
can_msgs = []
@@ -250,7 +279,7 @@ class Plant(object):
msg_struct = {}
indxs = [i for i, x in enumerate(msgs) if msg == msgs[i]]
for i in indxs:
- msg_struct[sgs[i]] = vls[i]
+ msg_struct[sgs[i]] = getattr(vls, sgs[i])
if "COUNTER" in honda.get_signals(msg):
msg_struct["COUNTER"] = self.rk.frame % 4
diff --git a/selfdrive/thermal.py b/selfdrive/thermal.py
deleted file mode 100644
index 24e4d6c52f..0000000000
--- a/selfdrive/thermal.py
+++ /dev/null
@@ -1,19 +0,0 @@
-"""Methods for reading system thermal information."""
-import selfdrive.messaging as messaging
-
-def read_tz(x):
- with open("/sys/devices/virtual/thermal/thermal_zone%d/temp" % x) as f:
- ret = max(0, int(f.read()))
- return ret
-
-def read_thermal():
- dat = messaging.new_message()
- dat.init('thermal')
- dat.thermal.cpu0 = read_tz(5)
- dat.thermal.cpu1 = read_tz(7)
- dat.thermal.cpu2 = read_tz(10)
- dat.thermal.cpu3 = read_tz(12)
- dat.thermal.mem = read_tz(2)
- dat.thermal.gpu = read_tz(16)
- dat.thermal.bat = read_tz(29)
- return dat
diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py
new file mode 100755
index 0000000000..97e63b1438
--- /dev/null
+++ b/selfdrive/thermald.py
@@ -0,0 +1,272 @@
+#!/usr/bin/env python2.7
+import os
+import zmq
+from smbus2 import SMBus
+
+from selfdrive.version import training_version
+from selfdrive.swaglog import cloudlog
+import selfdrive.messaging as messaging
+from selfdrive.services import service_list
+from selfdrive.loggerd.config import ROOT
+from common.params import Params
+from common.realtime import sec_since_boot
+
+import cereal
+ThermalStatus = cereal.log.ThermalData.ThermalStatus
+
+def read_tz(x):
+ with open("/sys/devices/virtual/thermal/thermal_zone%d/temp" % x) as f:
+ ret = max(0, int(f.read()))
+ return ret
+
+def read_thermal():
+ dat = messaging.new_message()
+ dat.init('thermal')
+ dat.thermal.cpu0 = read_tz(5)
+ dat.thermal.cpu1 = read_tz(7)
+ dat.thermal.cpu2 = read_tz(10)
+ dat.thermal.cpu3 = read_tz(12)
+ dat.thermal.mem = read_tz(2)
+ dat.thermal.gpu = read_tz(16)
+ dat.thermal.bat = read_tz(29)
+ return dat
+
+LEON = False
+def setup_eon_fan():
+ global LEON
+
+ os.system("echo 2 > /sys/module/dwc3_msm/parameters/otg_switch")
+
+ bus = SMBus(7, force=True)
+ try:
+ bus.write_byte_data(0x21, 0x10, 0xf) # mask all interrupts
+ bus.write_byte_data(0x21, 0x03, 0x1) # set drive current and global interrupt disable
+ bus.write_byte_data(0x21, 0x02, 0x2) # needed?
+ bus.write_byte_data(0x21, 0x04, 0x4) # manual override source
+ except IOError:
+ print "LEON detected"
+ #os.system("echo 1 > /sys/devices/soc/6a00000.ssusb/power_supply/usb/usb_otg")
+ LEON = True
+ bus.close()
+
+last_eon_fan_val = None
+def set_eon_fan(val):
+ global LEON, last_eon_fan_val
+
+ if last_eon_fan_val is None or last_eon_fan_val != val:
+ bus = SMBus(7, force=True)
+ if LEON:
+ i = [0x1, 0x3 | 0, 0x3 | 0x08, 0x3 | 0x10][val]
+ bus.write_i2c_block_data(0x3d, 0, [i])
+ else:
+ bus.write_byte_data(0x21, 0x04, 0x2)
+ bus.write_byte_data(0x21, 0x03, (val*2)+1)
+ bus.write_byte_data(0x21, 0x04, 0x4)
+ bus.close()
+ last_eon_fan_val = val
+
+# temp thresholds to control fan speed - high hysteresis
+_TEMP_THRS_H = [50., 65., 80., 10000]
+# temp thresholds to control fan speed - low hysteresis
+_TEMP_THRS_L = [42.5, 57.5, 72.5, 10000]
+# fan speed options
+_FAN_SPEEDS = [0, 16384, 32768, 65535]
+# max fan speed only allowed if battery if hot
+_BAT_TEMP_THERSHOLD = 45.
+
+def handle_fan(max_temp, bat_temp, fan_speed):
+ new_speed_h = next(speed for speed, temp_h in zip(_FAN_SPEEDS, _TEMP_THRS_H) if temp_h > max_temp)
+ new_speed_l = next(speed for speed, temp_l in zip(_FAN_SPEEDS, _TEMP_THRS_L) if temp_l > max_temp)
+
+ if new_speed_h > fan_speed:
+ # update speed if using the high thresholds results in fan speed increment
+ fan_speed = new_speed_h
+ elif new_speed_l < fan_speed:
+ # update speed if using the low thresholds results in fan speed decrement
+ fan_speed = new_speed_l
+
+ if bat_temp < _BAT_TEMP_THERSHOLD:
+ # no max fan speed unless battery is hot
+ fan_speed = min(fan_speed, _FAN_SPEEDS[-2])
+
+ set_eon_fan(fan_speed/16384)
+
+ return fan_speed
+
+class LocationStarter(object):
+ def __init__(self):
+ self.last_good_loc = 0
+ def update(self, started_ts, location):
+ rt = sec_since_boot()
+
+ if location is None or location.accuracy > 50 or location.speed < 2:
+ # bad location, stop if we havent gotten a location in a while
+ # dont stop if we're been going for less than a minute
+ if started_ts:
+ if rt-self.last_good_loc > 60. and rt-started_ts > 60:
+ cloudlog.event("location_stop",
+ ts=rt,
+ started_ts=started_ts,
+ last_good_loc=self.last_good_loc,
+ location=location.to_dict() if location else None)
+ return False
+ else:
+ return True
+ else:
+ return False
+
+ self.last_good_loc = rt
+
+ if started_ts:
+ return True
+ else:
+ cloudlog.event("location_start", location=location.to_dict() if location else None)
+ return location.speed*3.6 > 10
+
+def thermald_thread():
+ setup_eon_fan()
+
+ # now loop
+ context = zmq.Context()
+ thermal_sock = messaging.pub_sock(context, service_list['thermal'].port)
+ health_sock = messaging.sub_sock(context, service_list['health'].port)
+ location_sock = messaging.sub_sock(context, service_list['gpsLocation'].port)
+ fan_speed = 0
+ count = 0
+
+ off_ts = None
+ started_ts = None
+ ignition_seen = False
+ started_seen = False
+ passive_starter = LocationStarter()
+ thermal_status = ThermalStatus.green
+ health_sock.RCVTIMEO = 1500
+
+ params = Params()
+
+ while 1:
+ td = messaging.recv_sock(health_sock, wait=True)
+ location = messaging.recv_sock(location_sock)
+ location = location.gpsLocation if location else None
+ msg = read_thermal()
+
+ # loggerd is gated based on free space
+ statvfs = os.statvfs(ROOT)
+ avail = (statvfs.f_bavail * 1.0)/statvfs.f_blocks
+
+ # thermal message now also includes free space
+ msg.thermal.freeSpace = avail
+ with open("/sys/class/power_supply/battery/capacity") as f:
+ msg.thermal.batteryPercent = int(f.read())
+ with open("/sys/class/power_supply/battery/status") as f:
+ msg.thermal.batteryStatus = f.read().strip()
+ with open("/sys/class/power_supply/usb/online") as f:
+ msg.thermal.usbOnline = bool(int(f.read()))
+
+ # TODO: add car battery voltage check
+ max_temp = max(msg.thermal.cpu0, msg.thermal.cpu1,
+ msg.thermal.cpu2, msg.thermal.cpu3) / 10.0
+ bat_temp = msg.thermal.bat/1000.
+ fan_speed = handle_fan(max_temp, bat_temp, fan_speed)
+ msg.thermal.fanSpeed = fan_speed
+
+ # thermal logic here
+
+ if max_temp < 70.0:
+ thermal_status = ThermalStatus.green
+ if max_temp > 85.0:
+ cloudlog.warning("over temp: %r", max_temp)
+ thermal_status = ThermalStatus.yellow
+
+ # from controls
+ overtemp_proc = any(t > 950 for t in
+ (msg.thermal.cpu0, msg.thermal.cpu1, msg.thermal.cpu2,
+ msg.thermal.cpu3, msg.thermal.mem, msg.thermal.gpu))
+ overtemp_bat = msg.thermal.bat > 60000 # 60c
+ if overtemp_proc or overtemp_bat:
+ # TODO: hysteresis
+ thermal_status = ThermalStatus.red
+
+ if max_temp > 107.0 or msg.thermal.bat >= 63000:
+ thermal_status = ThermalStatus.danger
+
+ # **** starting logic ****
+
+ # start constellation of processes when the car starts
+ ignition = td is not None and td.health.started
+ ignition_seen = ignition_seen or ignition
+
+ # add voltage check for ignition
+ if not ignition_seen and td is not None and td.health.voltage > 13500:
+ ignition = True
+
+ do_uninstall = params.get("DoUninstall") == "1"
+ accepted_terms = params.get("HasAcceptedTerms") == "1"
+ completed_training = params.get("CompletedTrainingVersion") == training_version
+
+ should_start = ignition
+
+ # have we seen a panda?
+ passive = (params.get("Passive") == "1")
+
+ # start on gps movement if we haven't seen ignition and are in passive mode
+ should_start = should_start or (not (ignition_seen and td) # seen ignition and panda is connected
+ and passive
+ and passive_starter.update(started_ts, location))
+
+ # with 2% left, we killall, otherwise the phone will take a long time to boot
+ should_start = should_start and msg.thermal.freeSpace > 0.02
+
+ # require usb power in passive mode
+ should_start = should_start and (not passive or msg.thermal.usbOnline)
+
+ # confirm we have completed training and aren't uninstalling
+ should_start = should_start and accepted_terms and (passive or completed_training) and (not do_uninstall)
+
+ # if any CPU gets above 107 or the battery gets above 63, kill all processes
+ # controls will warn with CPU above 95 or battery above 60
+ if msg.thermal.thermalStatus >= ThermalStatus.danger:
+ # TODO: Add a better warning when this is happening
+ should_start = False
+
+ if should_start:
+ off_ts = None
+ if started_ts is None:
+ params.car_start()
+ started_ts = sec_since_boot()
+ started_seen = True
+ else:
+ started_ts = None
+ if off_ts is None:
+ off_ts = sec_since_boot()
+
+ # shutdown if the battery gets lower than 3%, it's discharging, we aren't running for
+ # more than a minute but we were running
+ if msg.thermal.batteryPercent < 3 and msg.thermal.batteryStatus == "Discharging" and \
+ started_seen and (sec_since_boot() - off_ts) > 60:
+ os.system('LD_LIBRARY_PATH="" svc power shutdown')
+
+ msg.thermal.started = started_ts is not None
+ msg.thermal.startedTs = int(1e9*(started_ts or 0))
+
+ msg.thermal.thermalStatus = thermal_status
+ thermal_sock.send(msg.to_bytes())
+ print msg
+
+ # report to server once per minute
+ if (count%60) == 0:
+ cloudlog.event("STATUS_PACKET",
+ count=count,
+ health=(td.to_dict() if td else None),
+ location=(location.to_dict() if location else None),
+ thermal=msg.to_dict())
+
+ count += 1
+
+
+def main(gctx=None):
+ thermald_thread()
+
+if __name__ == "__main__":
+ main()
+
diff --git a/selfdrive/ui/Makefile b/selfdrive/ui/Makefile
index 38b9147935..e9a5f6f84c 100644
--- a/selfdrive/ui/Makefile
+++ b/selfdrive/ui/Makefile
@@ -25,13 +25,21 @@ CEREAL_OBJS = ../../cereal/gen/c/log.capnp.o
NANOVG_FLAGS = -I$(PHONELIBS)/nanovg
JSON_FLAGS = -I$(PHONELIBS)/json/src
+OPENCL_FLAGS = -I$(PHONELIBS)/opencl/include
+OPENCL_LIBS = -lgsl -lCB -lOpenCL
+
OPENGL_LIBS = -lGLESv3
FRAMEBUFFER_LIBS = -lutils -lgui -lEGL
+CFLAGS += -DQCOM
+CXXFLAGS += -DQCOM
+
OBJS = ui.o \
../common/glutil.o \
../common/visionipc.o \
+ ../common/visionimg.o \
+ ../common/visionbuf_ion.o \
../common/framebuffer.o \
../common/params.o \
../common/util.o \
@@ -52,27 +60,33 @@ ui: $(OBJS)
$(CEREAL_LIBS) \
$(ZMQ_LIBS) \
-L/system/vendor/lib64 \
- -lhardware \
+ -lhardware -lui \
$(OPENGL_LIBS) \
- -lcutils -lm -llog
+ $(OPENCL_LIBS) \
+ -lcutils -lm -llog -lui -ladreno_utils
%.o: %.cc
@echo "[ CXX ] $@"
$(CXX) $(CXXFLAGS) -MMD \
-Iinclude -I.. -I../.. \
+ $(OPENCL_FLAGS) \
-I$(PHONELIBS)/android_frameworks_native/include \
-I$(PHONELIBS)/android_system_core/include \
-I$(PHONELIBS)/android_hardware_libhardware/include \
+ -I$(PHONELIBS)/libgralloc/include \
+ -I$(PHONELIBS)/linux/include \
-c -o '$@' '$<'
%.o: %.c
@echo "[ CC ] $@"
$(CC) $(CFLAGS) -MMD \
- -I.. -I../.. \
+ -Iinclude -I.. -I../.. \
$(NANOVG_FLAGS) \
$(ZMQ_FLAGS) \
$(CEREAL_CFLAGS) \
$(JSON_FLAGS) \
+ $(OPENCL_FLAGS) \
+ -I$(PHONELIBS)/linux/include \
-c -o '$@' '$<'
.PHONY: clean
diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c
index 17a31f493a..6948a492f5 100644
--- a/selfdrive/ui/ui.c
+++ b/selfdrive/ui/ui.c
@@ -4,12 +4,12 @@
#include
#include
#include
+#include
#include
#include
#include
-#include
#include
#include
@@ -28,6 +28,7 @@
#include "common/touch.h"
#include "common/framebuffer.h"
#include "common/visionipc.h"
+#include "common/visionimg.h"
#include "common/modeldata.h"
#include "common/params.h"
@@ -91,8 +92,6 @@ const int alert_sizes[] = {
typedef struct UIScene {
int frontview;
- uint8_t *bgr_ptr;
-
int transformed_width, transformed_height;
uint64_t model_ts;
@@ -110,6 +109,7 @@ typedef struct UIScene {
float v_ego;
float curvature;
int engaged;
+ bool engageable;
bool uilayout_sidebarcollapsed;
bool uilayout_mapenabled;
@@ -121,13 +121,13 @@ typedef struct UIScene {
int lead_status;
float lead_d_rel, lead_y_rel, lead_v_rel;
- uint8_t *bgr_front_ptr;
int front_box_x, front_box_y, front_box_width, front_box_height;
uint64_t alert_ts;
char alert_text1[1024];
char alert_text2[1024];
uint8_t alert_size;
+ float alert_blinkingrate;
float awareness_status;
@@ -190,8 +190,9 @@ typedef struct UIState {
int cur_vision_front_idx;
GLuint frame_program;
+ GLuint frame_texs[UI_BUF_COUNT];
+ GLuint frame_front_texs[UI_BUF_COUNT];
- GLuint frame_tex;
GLint frame_pos_loc, frame_texcoord_loc;
GLint frame_texture_loc, frame_transform_loc;
@@ -199,11 +200,12 @@ typedef struct UIState {
GLint line_pos_loc, line_color_loc;
GLint line_transform_loc;
- unsigned int rgb_width, rgb_height;
+ unsigned int rgb_width, rgb_height, rgb_stride;
+ size_t rgb_buf_len;
mat4 rgb_transform;
- unsigned int rgb_front_width, rgb_front_height;
- GLuint frame_front_tex;
+ unsigned int rgb_front_width, rgb_front_height, rgb_front_stride;
+ size_t rgb_front_buf_len;
bool intrinsic_matrix_loaded;
mat3 intrinsic_matrix;
@@ -217,6 +219,8 @@ typedef struct UIState {
bool is_metric;
bool passive;
int alert_size;
+ float alert_blinking_alpha;
+ bool alert_blinked;
float light_sensor;
} UIState;
@@ -469,9 +473,13 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
s->rgb_width = back_bufs.width;
s->rgb_height = back_bufs.height;
+ s->rgb_stride = back_bufs.stride;
+ s->rgb_buf_len = back_bufs.buf_len;
s->rgb_front_width = front_bufs.width;
s->rgb_front_height = front_bufs.height;
+ s->rgb_front_stride = front_bufs.stride;
+ s->rgb_front_buf_len = front_bufs.buf_len;
s->rgb_transform = (mat4){{
2.0/s->rgb_width, 0.0, 0.0, -1.0,
@@ -488,30 +496,6 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
}
}
-static void ui_update_frame(UIState *s) {
- assert(glGetError() == GL_NO_ERROR);
-
- UIScene *scene = &s->scene;
-
- if (scene->frontview && scene->bgr_front_ptr) {
- // load front frame texture
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, s->frame_front_tex);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
- s->rgb_front_width, s->rgb_front_height,
- GL_RGB, GL_UNSIGNED_BYTE, scene->bgr_front_ptr);
- } else if (!scene->frontview && scene->bgr_ptr) {
- // load frame texture
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, s->frame_tex);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
- s->rgb_width, s->rgb_height,
- GL_RGB, GL_UNSIGNED_BYTE, scene->bgr_ptr);
- }
-
- assert(glGetError() == GL_NO_ERROR);
-}
-
static void ui_draw_transformed_box(UIState *s, uint32_t color) {
const UIScene *scene = &s->scene;
@@ -808,10 +792,10 @@ static void draw_frame(UIState *s) {
};
glActiveTexture(GL_TEXTURE0);
- if (s->scene.frontview) {
- glBindTexture(GL_TEXTURE_2D, s->frame_front_tex);
- } else {
- glBindTexture(GL_TEXTURE_2D, s->frame_tex);
+ if (s->scene.frontview && s->cur_vision_front_idx >= 0) {
+ glBindTexture(GL_TEXTURE_2D, s->frame_front_texs[s->cur_vision_front_idx]);
+ } else if (!scene->frontview && s->cur_vision_idx >= 0) {
+ glBindTexture(GL_TEXTURE_2D, s->frame_texs[s->cur_vision_idx]);
}
glUseProgram(s->frame_program);
@@ -972,16 +956,19 @@ static void ui_draw_vision_wheel(UIState *s) {
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.5f;
+ float img_wheel_alpha = 0.1f;
bool is_engaged = (s->status == STATUS_ENGAGED);
bool is_warning = (s->status == STATUS_WARNING);
- if (is_engaged || is_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;
@@ -1031,7 +1018,7 @@ static void ui_draw_vision_alert(UIState *s, int va_size, int va_color,
nvgBeginPath(s->vg);
nvgRect(s->vg, alr_x, alr_y, alr_w, alr_h);
- nvgFillColor(s->vg, nvgRGBA(color[0],color[1],color[2],color[3]));
+ nvgFillColor(s->vg, nvgRGBA(color[0],color[1],color[2],(color[3]*s->alert_blinking_alpha)));
nvgFill(s->vg);
nvgBeginPath(s->vg);
@@ -1151,7 +1138,6 @@ static void ui_draw(UIState *s) {
glDisable(GL_BLEND);
}
- eglSwapBuffers(s->display, s->surface);
assert(glGetError() == GL_NO_ERROR);
}
@@ -1211,31 +1197,53 @@ static void ui_update(UIState *s) {
// cant run this in connector thread because opengl.
// do this here for now in lieu of a run_on_main_thread event
- // setup frame texture
- glDeleteTextures(1, &s->frame_tex); //silently ignores a 0 texture
- glGenTextures(1, &s->frame_tex);
- glBindTexture(GL_TEXTURE_2D, s->frame_tex);
- glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGB8, s->rgb_width, s->rgb_height);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- // BGR
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
-
- // front
- glDeleteTextures(1, &s->frame_front_tex);
- glGenTextures(1, &s->frame_front_tex);
- glBindTexture(GL_TEXTURE_2D, s->frame_front_tex);
- glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGB8, s->rgb_front_width, s->rgb_front_height);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- // BGR
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ for (int i=0; iframe_texs[i]);
+
+ VisionImg img = {
+ .fd = s->bufs[i].fd,
+ .format = VISIONIMG_FORMAT_RGB24,
+ .width = s->rgb_width,
+ .height = s->rgb_height,
+ .stride = s->rgb_stride,
+ .bpp = 3,
+ .size = s->rgb_buf_len,
+ };
+ s->frame_texs[i] = visionimg_to_gl(&img);
+
+ glBindTexture(GL_TEXTURE_2D, s->frame_texs[i]);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ // BGR
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ }
+
+ for (int i=0; iframe_front_texs[i]);
+
+ VisionImg img = {
+ .fd = s->front_bufs[i].fd,
+ .format = VISIONIMG_FORMAT_RGB24,
+ .width = s->rgb_front_width,
+ .height = s->rgb_front_height,
+ .stride = s->rgb_front_stride,
+ .bpp = 3,
+ .size = s->rgb_front_buf_len,
+ };
+ s->frame_front_texs[i] = visionimg_to_gl(&img);
+
+ glBindTexture(GL_TEXTURE_2D, s->frame_front_texs[i]);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ // BGR
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ }
assert(glGetError() == GL_NO_ERROR);
@@ -1245,6 +1253,9 @@ static void ui_update(UIState *s) {
s->scene.ui_viz_ro = 0;
s->vision_connect_firstrun = false;
+
+ s->alert_blinking_alpha = 1.0;
+ s->alert_blinked = false;
}
// poll for events
@@ -1302,7 +1313,7 @@ static void ui_update(UIState *s) {
continue;
}
if (rp.type == VIPC_STREAM_ACQUIRE) {
- bool front = rp.d.stream_acq.type == VISION_STREAM_UI_FRONT;
+ bool front = rp.d.stream_acq.type == VISION_STREAM_RGB_FRONT;
int idx = rp.d.stream_acq.idx;
int release_idx;
@@ -1325,17 +1336,11 @@ static void ui_update(UIState *s) {
if (front) {
assert(idx < UI_BUF_COUNT);
s->cur_vision_front_idx = idx;
- s->scene.bgr_front_ptr = s->front_bufs[idx].addr;
} else {
assert(idx < UI_BUF_COUNT);
s->cur_vision_idx = idx;
- s->scene.bgr_ptr = s->bufs[idx].addr;
// printf("v %d\n", ((uint8_t*)s->bufs[idx].addr)[0]);
}
- if (front == s->scene.frontview) {
- ui_update_frame(s);
- }
-
} else {
assert(false);
}
@@ -1392,6 +1397,7 @@ static void ui_update(UIState *s) {
s->scene.v_ego = datad.vEgo;
s->scene.curvature = datad.curvature;
s->scene.engaged = datad.enabled;
+ s->scene.engageable = datad.engageable;
s->scene.gps_planner_active = datad.gpsPlannerActive;
// printf("recv %f\n", datad.vEgo);
@@ -1431,6 +1437,24 @@ static void ui_update(UIState *s) {
update_status(s, STATUS_DISENGAGED);
}
+ s->scene.alert_blinkingrate = datad.alertBlinkingRate;
+ if (datad.alertBlinkingRate > 0.) {
+ if (s->alert_blinked) {
+ if (s->alert_blinking_alpha > 0.0 && s->alert_blinking_alpha < 1.0) {
+ s->alert_blinking_alpha += (0.05*datad.alertBlinkingRate);
+ } else {
+ s->alert_blinked = false;
+ }
+ } else {
+ if (s->alert_blinking_alpha > 0.25) {
+ s->alert_blinking_alpha -= (0.05*datad.alertBlinkingRate);
+ } else {
+ s->alert_blinking_alpha += 0.25;
+ s->alert_blinked = true;
+ }
+ }
+ }
+
} else if (eventd.which == cereal_Event_live20) {
struct cereal_Live20Data datad;
cereal_read_Live20Data(&datad, eventd.live20);
@@ -1570,8 +1594,8 @@ static void* vision_connect_thread(void *args) {
if (fd < 0) continue;
VisionPacket back_rp, front_rp;
- if (!vision_subscribe(fd, &back_rp, VISION_STREAM_UI_BACK)) continue;
- if (!vision_subscribe(fd, &front_rp, VISION_STREAM_UI_FRONT)) continue;
+ if (!vision_subscribe(fd, &back_rp, VISION_STREAM_RGB_BACK)) continue;
+ if (!vision_subscribe(fd, &front_rp, VISION_STREAM_RGB_FRONT)) continue;
pthread_mutex_lock(&s->lock);
assert(!s->vision_connected);
@@ -1649,28 +1673,24 @@ static void* bg_thread(void* args) {
&bg_display, &bg_surface, NULL, NULL);
assert(bg_fb);
- bool first = true;
+ int bg_status = -1;
while(!do_exit) {
pthread_mutex_lock(&s->lock);
-
- if (first) {
- first = false;
- } else {
+ if (bg_status == s->status) {
+ // will always be signaled if it changes?
pthread_cond_wait(&s->bg_cond, &s->lock);
}
-
- assert(s->status < ARRAYSIZE(bg_colors));
- const uint8_t *color = bg_colors[s->status];
-
+ bg_status = s->status;
pthread_mutex_unlock(&s->lock);
+ assert(bg_status < ARRAYSIZE(bg_colors));
+ const uint8_t *color = bg_colors[bg_status];
+
glClearColor(color[0]/256.0, color[1]/256.0, color[2]/256.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
-
eglSwapBuffers(bg_display, bg_surface);
assert(glGetError() == GL_NO_ERROR);
-
}
return NULL;
@@ -1679,6 +1699,7 @@ static void* bg_thread(void* args) {
int main() {
int err;
+ setpriority(PRIO_PROCESS, 0, -14);
zsys_handler_set(NULL);
signal(SIGINT, (sighandler_t)set_do_exit);
@@ -1716,6 +1737,7 @@ int main() {
const int EON = (access("/EON", F_OK) != -1);
while (!do_exit) {
+ bool should_swap = false;
pthread_mutex_lock(&s->lock);
if (EON) {
@@ -1731,13 +1753,10 @@ int main() {
}
ui_update(s);
- if (s->awake) {
- ui_draw(s);
- }
// awake on any touch
int touch_x = -1, touch_y = -1;
- int touched = touch_poll(&touch, &touch_x, &touch_y);
+ int touched = touch_poll(&touch, &touch_x, &touch_y, s->awake ? 0 : 100);
if (touched == 1) {
// touch event will still happen :(
set_awake(s, true);
@@ -1750,10 +1769,19 @@ int main() {
set_awake(s, false);
}
+ if (s->awake) {
+ ui_draw(s);
+ glFinish();
+ should_swap = true;
+ }
+
pthread_mutex_unlock(&s->lock);
- // no simple way to do 30fps vsync with surfaceflinger...
- usleep(30000);
+ // the bg thread needs to be scheduled, so the main thread needs time without the lock
+ // safe to do this outside the lock?
+ if (should_swap) {
+ eglSwapBuffers(s->display, s->surface);
+ }
}
set_awake(s, true);
diff --git a/selfdrive/updated.py b/selfdrive/updated.py
index fd5887e111..c8efd8f3a8 100755
--- a/selfdrive/updated.py
+++ b/selfdrive/updated.py
@@ -1,12 +1,9 @@
#!/usr/bin/env python
-# simple service that waits for network access and tries to update every 3 hours
+# simple service that waits for network access and tries to update every hour
-import os
import time
import subprocess
-
-from common.basedir import BASEDIR
from selfdrive.swaglog import cloudlog
NICE_LOW_PRIORITY = ["nice", "-n", "19"]
@@ -19,17 +16,18 @@ def main(gctx=None):
continue
# download application update
- r = subprocess.call(NICE_LOW_PRIORITY + ["git", "fetch"])
- cloudlog.info("git fetch: %r", r)
- if r:
+ try:
+ r = subprocess.check_output(NICE_LOW_PRIORITY + ["git", "fetch"], stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError, e:
+ cloudlog.event("git fetch failed",
+ cmd=e.cmd,
+ output=e.output,
+ returncode=e.returncode)
time.sleep(60)
continue
+ cloudlog.info("git fetch success: %s", r)
- # download apks
- r = subprocess.call(NICE_LOW_PRIORITY + [os.path.join(BASEDIR, "apk/external/patcher.py"), "download"])
- cloudlog.info("patcher download: %r", r)
-
- time.sleep(60*60*3)
+ time.sleep(60*60)
if __name__ == "__main__":
main()
diff --git a/selfdrive/visiond/visiond b/selfdrive/visiond/visiond
index 8c77ab9139..1a4867061e 100755
Binary files a/selfdrive/visiond/visiond and b/selfdrive/visiond/visiond differ