openpilot v0.7.5 release

Vehicle Researcher 2020-05-09 13:01:35 -07:00
parent 7e908db510
commit ddee718536
237 changed files with 16444 additions and 5626 deletions

3
.gitignore vendored
View File

@ -20,7 +20,9 @@ a.out
.*.un~
*.tmp
*.o
*.o-*
*.os
*.os-*
*.so
*.a
*.clb
@ -54,6 +56,7 @@ xx
panda_jungle
.coverage*
coverage.xml
htmlcov
pandaextra

164
README.md
View File

@ -57,106 +57,125 @@ openpilot should preserve all other vehicle's stock features, including, but are
Supported Hardware
------
At the moment, openpilot supports the [EON DevKit](https://comma.ai/shop/products/eon-dashcam-devkit) and the [comma two](https://comma.ai/shop/products/comma-two-devkit). A [car harness](https://comma.ai/shop/products/car-harness) is recommended to connect the EON or comma two to the car. In the future, we'd like to support other platforms as well, like gaming PCs.
At the moment, openpilot supports the [EON DevKit](https://comma.ai/shop/products/eon-dashcam-devkit) and the [comma two](https://comma.ai/shop/products/comma-two-devkit). A [car harness](https://comma.ai/shop/products/car-harness) is recommended to connect the EON or comma two to the car. For experimental purposes, openpilot can also run on an Ubuntu computer with external [webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam).
Supported Cars
------
| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below |
| ----------| ------------------------------| ------------------| -----------------| -------------------| ------------------|
| Acura | ILX 2016-18 | AcuraWatch Plus | openpilot | 25mph<sup>6</sup> | 25mph |
| Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph<sup>6</sup> | 12mph |
| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Chrysler | Pacifica Hybrid 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph |
| Acura | ILX 2016-18 | AcuraWatch Plus | openpilot | 25mph<sup>1</sup> | 25mph |
| Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Accord 2018-19 | All | Stock | 0mph | 3mph |
| Honda | Accord Hybrid 2018-19 | All | Stock | 0mph | 3mph |
| Honda | Civic Hatchback 2017-19 | Honda Sensing | Stock | 0mph | 12mph |
| Honda | Civic Sedan/Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph |
| Honda | Civic Sedan/Coupe 2019 | Honda Sensing | Stock | 0mph | 2mph<sup>4</sup> |
| Honda | CR-V 2015-16 | Touring | openpilot | 25mph<sup>6</sup> | 12mph |
| Honda | Civic Sedan/Coupe 2019-20 | Honda Sensing | Stock | 0mph | 2mph<sup>2</sup> |
| Honda | CR-V 2015-16 | Touring | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | CR-V 2017-19 | Honda Sensing | Stock | 0mph | 12mph |
| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph |
| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph<sup>6</sup> | 12mph |
| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | HR-V 2019 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Insight 2019 | Honda Sensing | Stock | 0mph | 3mph |
| Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph<sup>6</sup> | 0mph |
| Honda | Passport 2019 | All | openpilot | 25mph<sup>6</sup> | 12mph |
| Honda | Pilot 2016-18 | Honda Sensing | openpilot | 25mph<sup>6</sup> | 12mph |
| Honda | Pilot 2019 | All | openpilot | 25mph<sup>6</sup> | 12mph |
| Honda | Ridgeline 2017-19 | Honda Sensing | openpilot | 25mph<sup>6</sup> | 12mph |
| Hyundai | Elantra 2017-19<sup>1</sup> | SCC + LKAS | Stock | 19mph | 34mph |
| Hyundai | Genesis 2018<sup>1</sup> | All | Stock | 19mph | 34mph |
| Hyundai | Santa Fe 2019<sup>1</sup> | All | Stock | 0mph | 0mph |
| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Jeep | Grand Cherokee 2019 | Adaptive Cruise | Stock | 0mph | 39mph |
| Kia | Optima 2019<sup>1</sup> | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Sorento 2018<sup>1</sup> | All | Stock | 0mph | 0mph |
| Kia | Stinger 2018<sup>1</sup> | SCC + LKAS | Stock | 0mph | 0mph |
| Lexus | CT Hybrid 2017-18 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 0mph |
| Honda | Passport 2019 | All | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Pilot 2016-18 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Pilot 2019 | All | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Ridgeline 2017-20 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Lexus | CT Hybrid 2017-18 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | ES 2019 | All | openpilot | 0mph | 0mph |
| Lexus | ES Hybrid 2019 | All | openpilot | 0mph | 0mph |
| Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph |
| Lexus | IS Hybrid 2017 | All | Stock | 0mph | 0mph |
| Lexus | NX Hybrid 2018 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Lexus | RX 2016-17 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Lexus | NX Hybrid 2018 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | RX 2016-17 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | RX 2020 | All | openpilot | 0mph | 0mph |
| Lexus | RX Hybrid 2016-19 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph |
| Subaru | Impreza 2019-20 | EyeSight | Stock | 0mph | 0mph |
| Toyota | Avalon 2016 | TSS-P | Stock<sup>5</sup>| 20mph<sup>6</sup> | 0mph |
| Toyota | Avalon 2017-18 | All | Stock<sup>5</sup>| 20mph<sup>6</sup> | 0mph |
| Toyota | Camry 2018-19 | All | Stock | 0mph<sup>2</sup> | 0mph |
| Toyota | Camry Hybrid 2018-19 | All | Stock | 0mph<sup>2</sup> | 0mph |
| Lexus | RX Hybrid 2016-19 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Avalon 2016 | TSS-P | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Avalon 2017-18 | All | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Camry 2018-20 | All | Stock | 0mph<sup>4</sup> | 0mph |
| Toyota | Camry Hybrid 2018-19 | All | Stock | 0mph<sup>4</sup> | 0mph |
| Toyota | C-HR 2017-19 | All | Stock | 0mph | 0mph |
| Toyota | C-HR Hybrid 2017-19 | All | Stock | 0mph | 0mph |
| Toyota | Corolla 2017-19 | All | Stock<sup>5</sup>| 20mph<sup>6</sup> | 0mph |
| Toyota | Corolla 2017-19 | All | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Corolla 2020 | All | openpilot | 0mph | 0mph |
| Toyota | Corolla Hatchback 2019-20 | All | openpilot | 0mph | 0mph |
| Toyota | Corolla Hybrid 2020 | All | openpilot | 0mph | 0mph |
| Toyota | Highlander 2017-19 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Toyota | Highlander Hybrid 2017-19 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Toyota | Highlander 2017-19 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Highlander Hybrid 2017-19 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Highlander 2020 | All | openpilot | 0mph | 0mph |
| Toyota | Prius 2016 | TSS-P | Stock<sup>5</sup>| 0mph | 0mph |
| Toyota | Prius 2017-19 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Toyota | Prius Prime 2017-20 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Toyota | Rav4 2016 | TSS-P | Stock<sup>5</sup>| 20mph<sup>6</sup> | 0mph |
| Toyota | Rav4 2017-18 | All | Stock<sup>5</sup>| 20mph<sup>6</sup> | 0mph |
| Toyota | Rav4 2019 | All | openpilot | 0mph | 0mph |
| Toyota | Rav4 Hybrid 2016 | TSS-P | Stock<sup>5</sup>| 0mph | 0mph |
| Toyota | Rav4 Hybrid 2017-18 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Toyota | Highlander Hybrid 2020 | All | openpilot | 0mph | 0mph |
| Toyota | Prius 2016 | TSS-P | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Prius 2017-19 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Prius Prime 2017-20 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Rav4 2016 | TSS-P | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Rav4 2017-18 | All | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Rav4 2019-20 | All | openpilot | 0mph | 0mph |
| Toyota | Rav4 Hybrid 2016 | TSS-P | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Rav4 Hybrid 2017-18 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Rav4 Hybrid 2019-20 | All | openpilot | 0mph | 0mph |
| Toyota | Sienna 2018 | All | Stock<sup>5</sup>| 0mph | 0mph |
| Volkswagen| Golf 2016-19<sup>3</sup> | Driver Assistance | Stock | 0mph | 0mph |
| Toyota | Sienna 2018 | All | Stock<sup>3</sup>| 0mph | 0mph |
<sup>1</sup>Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and open sourced [Hyundai giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai), designed for the 2019 Sante Fe; pinout may differ for other Hyundai and Kia models. <br />
<sup>2</sup>28mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control. <br />
<sup>3</sup>Requires a [custom connector](https://community.comma.ai/wiki/index.php/Volkswagen#Integration_at_R242_Camera) for the [car harness](https://comma.ai/shop/products/car-harness) <br />
<sup>4</sup>2019 Honda Civic 1.6L Diesel Sedan does not have ALC below 12mph. <br />
<sup>1</sup>[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](https://comma.ai).*** <br />
<sup>2</sup>2019 Honda Civic 1.6L Diesel Sedan does not have ALC below 12mph. <br />
<sup>3</sup>When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota). ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).*** <br />
<sup>4</sup>28mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control. <br />
Community Maintained Cars and Features
------
| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below |
| ----------| ------------------------------| ------------------| -----------------| -------------------| -------------|
| Buick | Regal 2018<sup>7</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Cadillac | ATS 2018<sup>7</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Chevrolet | Malibu 2017<sup>7</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Chevrolet | Volt 2017-18<sup>7</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| GMC | Acadia Denali 2018<sup>7</sup>| Adaptive Cruise | openpilot | 0mph | 7mph |
| Holden | Astra 2017<sup>7</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Buick | Regal 2018<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Cadillac | ATS 2018<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Chevrolet | Malibu 2017<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Chevrolet | Volt 2017-18<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Chrysler | Pacifica 2020 | Adaptive Cruise | Stock | 0mph | 39mph |
| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Chrysler | Pacifica Hybrid 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph |
| Genesis | G80 2018<sup>2</sup> | All | Stock | 0mph | 0mph |
| Genesis | G90 2018<sup>2</sup> | All | Stock | 0mph | 0mph |
| GMC | Acadia Denali 2018<sup>3</sup>| Adaptive Cruise | openpilot | 0mph | 7mph |
| Holden | Astra 2017<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Hyundai | Elantra 2017-19<sup>2</sup> | SCC + LKAS | Stock | 19mph | 34mph |
| Hyundai | Genesis 2015-16<sup>2</sup> | SCC + LKAS | Stock | 19mph | 37mph |
| Hyundai | Ioniq 2017<sup>2</sup> | SCC + LKAS | Stock | 0mph | 32mph |
| Hyundai | Ioniq 2019 EV<sup>2</sup> | SCC + LKAS | Stock | 0mph | 32mph |
| Hyundai | Kona 2017-19<sup>2</sup> | SCC + LKAS | Stock | 22mph | 0mph |
| Hyundai | Kona 2019 EV<sup>2</sup> | SCC + LKAS | Stock | 0mph | 0mph |
| Hyundai | Palisade 2020<sup>2</sup> | All | Stock | 0mph | 0mph |
| Hyundai | Santa Fe 2019<sup>2</sup> | All | Stock | 0mph | 0mph |
| Hyundai | Sonata 2020<sup>2</sup> | All | Stock | 0mph | 0mph |
| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Jeep | Grand Cherokee 2019 | Adaptive Cruise | Stock | 0mph | 39mph |
| Kia | Forte 2018<sup>2</sup> | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Optima 2017<sup>2</sup> | SCC + LKAS/LDWS | Stock | 0mph | 32mph |
| Kia | Optima 2019<sup>2</sup> | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Sorento 2018<sup>2</sup> | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Stinger 2018<sup>2</sup> | SCC + LKAS | Stock | 0mph | 0mph |
| Nissan | Leaf 2019 | Propilot | Stock | 0mph | 0mph |
| Nissan | X-Trail 2018 | Propilot | Stock | 0mph | 0mph |
| Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph |
| Subaru | Impreza 2018-20 | EyeSight | Stock | 0mph | 0mph |
| Volkswagen| Golf 2016-19<sup>3</sup> | Driver Assistance | Stock | 0mph | 0mph |
<sup>5</sup>When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota). ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).*** <br />
<sup>6</sup>[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](https://comma.ai).*** <br />
<sup>7</sup>Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and [community built giraffe](https://zoneos.com/volt/). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).*** <br />
<sup>1</sup>Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and [community built giraffe](https://zoneos.com/volt/). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).*** <br />
<sup>2</sup>Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and open sourced [Hyundai giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai), designed for the 2019 Sante Fe; pinout may differ for other Hyundai and Kia models. <br />
<sup>3</sup>Requires a [custom connector](https://community.comma.ai/wiki/index.php/Volkswagen#Integration_at_R242_Camera) for the [car harness](https://comma.ai/shop/products/car-harness) <br />
Although it's not upstream, there's a community of people getting openpilot to run on Tesla's [here](https://tinkla.us/)
Community Maintained Cars and Features are not verified by comma to meet our [safety model](SAFETY.md). Be extra cautious using them. They are only available after enabling the toggle in `Settings->Developer->Enable Community Features`.
To promote a car from community maintained, it must meet a few requirements. We must own one from the brand, we must sell the harness for it, has full ISO26262 in both panda and openpilot, there must be a path forward for longitudinal control, it must have AEB still enabled, and it must support fingerprinting 2.0
Installation Instructions
------
Install openpilot on a EON by entering ``https://openpilot.comma.ai`` during the installer setup.
Install openpilot on an EON or comma two by entering ``https://openpilot.comma.ai`` during the installer setup.
Follow this [video instructions](https://youtu.be/3nlkomHathI) to properly mount the EON on the windshield. Note: openpilot features an automatic pose calibration routine and openpilot performance should not be affected by small pitch and yaw misalignments caused by imprecise EON mounting.
Follow these [video instructions](https://youtu.be/3nlkomHathI) to properly mount the device on the windshield. Note: openpilot features an automatic pose calibration routine and openpilot performance should not be affected by small pitch and yaw misalignments caused by imprecise device mounting.
Before placing the device on your windshield, check the state and local laws and ordinances where you drive. Some state laws prohibit or restrict the placement of objects on the windshield of a motor vehicle.
@ -174,7 +193,7 @@ Many factors can impact the performance of openpilot ALC and openpilot LDW, caus
* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation.
* The road facing camera is obstructed, covered or damaged by mud, ice, snow, etc.
* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle.
* The EON is mounted incorrectly.
* The device is mounted incorrectly.
* When in sharp curves, like on-off ramps, intersections etc...; openpilot is designed to be limited in the amount of steering torque it can produce.
* In the presence of restricted lanes or construction zones.
* When driving on highly banked roads or in presence of strong cross-wind.
@ -194,7 +213,7 @@ Many factors can impact the performance of openpilot ACC and openpilot FCW, caus
* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation.
* The road facing camera or radar are obstructed, covered, or damaged by mud, ice, snow, etc.
* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle.
* The EON is mounted incorrectly.
* The device is mounted incorrectly.
* Approaching a toll booth, a bridge or a large metal plate.
* When driving on roads with pedestrians, cyclists, etc...
* In presence of traffic signs or stop lights, which are not detected by openpilot at this time.
@ -212,13 +231,13 @@ The list above does not represent an exhaustive list of situations that may inte
Limitations of openpilot DM
------
openpilot DM should not be considered an exact measurements of the status of alertness of the driver.
openpilot DM should not be considered an exact measurement of the alertness of the driver.
Many factors can impact the performance of openpilot DM, causing it to be unable to function as intended. These include, but are not limited to:
* Low light conditions, such as driving at night or in dark tunnels.
* Bright light (due to oncoming headlights, direct sunlight, etc.).
* The driver face is partially or completely outside field of view of the driver facing camera.
* The driver's face is partially or completely outside field of view of the driver facing camera.
* Right hand driving vehicles.
* The driver facing camera is obstructed, covered, or damaged.
@ -240,7 +259,7 @@ Safety and Testing
----
* openpilot observes ISO26262 guidelines, see [SAFETY.md](SAFETY.md) for more detail.
* openpilot has software in the loop [tests](run_docker_tests.sh) that run on every commit.
* openpilot has software in the loop [tests](.github/workflows/test.yaml) that run on every commit.
* The safety model code lives in panda and is written in C, see [code rigor](https://github.com/commaai/panda#code-rigor) for more details.
* panda has software in the loop [safety tests](https://github.com/commaai/panda/tree/master/tests/safety).
* Internally, we have a hardware in the loop Jenkins test suite that builds and unit tests the various processes.
@ -267,15 +286,15 @@ Directory Structure
------
.
├── apk # The apk files used for the UI
├── cereal # The messaging spec and libs used for all logs on EON
├── cereal # The messaging spec and libs used for all logs
├── 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
├── phonelibs # Libraries used on EON
├── pyextra # Libraries used on EON
├── phonelibs # Libraries used on NEOS devices
├── pyextra # Libraries used on NEOS devices
└── selfdrive # Code needed to drive the car
├── assets # Fonts and images for UI
├── assets # Fonts, images, and sounds for UI
├── athena # Allows communication with the app
├── boardd # Daemon to talk to the board
├── camerad # Driver to capture images from the camera sensors
@ -289,7 +308,7 @@ Directory Structure
├── modeld # Driving and monitoring model runners
├── proclogd # Logs information from proc
├── sensord # IMU / GPS interface code
├── tests # Unit tests, system tests and a car simulator
├── test # Unit tests, system tests and a car simulator
└── ui # The UI
To understand how the services interact, see `cereal/service_list.yaml`.
@ -308,3 +327,8 @@ NO WARRANTY EXPRESSED OR IMPLIED.**
---
<img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/1061157-bc7e9bf3b246ece7322e6ffe653f6af8-medium_jpg.jpg?buster=1458363130" width="75"></img> <img src="https://cdn-images-1.medium.com/max/1600/1*C87EjxGeMPrkTuVRVWVg4w.png" width="225"></img>
[![Total alerts](https://img.shields.io/lgtm/alerts/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:python)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:cpp)
[![codecov](https://codecov.io/gh/commaai/openpilot/branch/master/graph/badge.svg)](https://codecov.io/gh/commaai/openpilot)

View File

@ -1,3 +1,13 @@
Version 0.7.5 (2020-05-13)
========================
* Right-Hand Drive support for both driving and driver monitoring!
* New driving model: improved at sharp turns and lead speed estimation
* New driver monitoring model: overall improvement on comma two
* Driver camera preview in settings to improve mounting position
* Added support for many Hyundai, Kia, Genesis models thanks to xx979xx!
* 2019 Nissan X-Trail and 2018 Nissan Leaf support thanks to avolmensky!
* Improved lateral tuning for 2020 Toyota Rav 4 (hybrid)
Version 0.7.4 (2020-03-20)
========================
* New driving model: improved lane changes and lead car detection

View File

@ -14,39 +14,55 @@ AddOption('--asan',
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
if platform.system() == "Darwin":
arch = "Darwin"
if arch == "aarch64" and not os.path.isdir("/system"):
arch = "larch64"
if arch == "aarch64":
webcam = bool(ARGUMENTS.get("use_webcam", 0))
if arch == "aarch64" or arch == "larch64":
lenv = {
"LD_LIBRARY_PATH": '/data/data/com.termux/files/usr/lib',
"PATH": os.environ['PATH'],
"ANDROID_DATA": os.environ['ANDROID_DATA'],
"ANDROID_ROOT": os.environ['ANDROID_ROOT'],
}
if arch == "aarch64":
# android
lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA']
lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT']
cpppath = [
"#phonelibs/opencl/include",
]
libpath = [
"#phonelibs/snpe/aarch64-android-clang3.8",
"/usr/lib",
"/data/data/com.termux/files/usr/lib",
"/system/vendor/lib64",
"/system/comma/usr/lib",
"#phonelibs/nanovg",
"#phonelibs/libyuv/lib",
]
cflags = ["-DQCOM", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM", "-mcpu=cortex-a57"]
if arch == "larch64":
cpppath += ["#phonelibs/capnp-cpp/include"]
libpath += ["#phonelibs/snpe/larch64"]
libpath += ["#phonelibs/libyuv/larch64/lib"]
libpath += ["#external/capnparm/lib", "/usr/lib/aarch64-linux-gnu"]
cflags = ["-DQCOM2", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"]
rpath = ["/usr/local/lib"]
else:
libpath += ["#phonelibs/snpe/aarch64"]
libpath += ["#phonelibs/libyuv/lib"]
cflags = ["-DQCOM", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM", "-mcpu=cortex-a57"]
rpath = ["/system/vendor/lib64"]
rpath = ["/system/vendor/lib64"]
else:
lenv = {
"PATH": "#external/bin:" + os.environ['PATH'],
}
cpppath = [
"#phonelibs/capnp-cpp/include",
"#phonelibs/capnp-c/include",
"#phonelibs/zmq/x64/include",
"#external/tensorflow/include",
]
@ -54,7 +70,6 @@ else:
if arch == "Darwin":
libpath = [
"#phonelibs/capnp-cpp/mac/lib",
"#phonelibs/capnp-c/mac/lib",
"#phonelibs/libyuv/mac/lib",
"#cereal",
"#selfdrive/common",
@ -64,7 +79,6 @@ else:
else:
libpath = [
"#phonelibs/capnp-cpp/x64/lib",
"#phonelibs/capnp-c/x64/lib",
"#phonelibs/snpe/x86_64-linux-clang",
"#phonelibs/zmq/x64/lib",
"#phonelibs/libyuv/x64/lib",
@ -113,11 +127,10 @@ env = Environment(
"#phonelibs/bzip2",
"#phonelibs/libyuv/include",
"#phonelibs/openmax/include",
"#phonelibs/json/src",
"#phonelibs/json11",
"#phonelibs/eigen",
"#phonelibs/curl/include",
"#phonelibs/opencv/include",
#"#phonelibs/opencv/include", # use opencv4 instead
"#phonelibs/libgralloc/include",
"#phonelibs/android_frameworks_native/include",
"#phonelibs/android_hardware_libhardware/include",
@ -175,10 +188,12 @@ def abspath(x):
# rpath works elsewhere
return x[0].path.rsplit("/", 1)[1][:-3]
#zmq = 'zmq'
# still needed for apks
zmq = FindFile("libzmq.a", libpath)
Export('env', 'arch', 'zmq', 'SHARED')
if arch == 'larch64':
zmq = 'zmq'
else:
zmq = FindFile("libzmq.a", libpath)
Export('env', 'arch', 'zmq', 'SHARED', 'webcam')
# cereal and messaging are shared with the system
SConscript(['cereal/SConscript'])
@ -196,7 +211,7 @@ Import('_common', '_visionipc', '_gpucommon', '_gpu_libs')
if SHARED:
common, visionipc, gpucommon = abspath(common), abspath(visionipc), abspath(gpucommon)
else:
common = [_common, 'json']
common = [_common, 'json11']
visionipc = _visionipc
gpucommon = [_gpucommon] + _gpu_libs
@ -215,6 +230,7 @@ if arch != "Darwin":
SConscript(['selfdrive/controls/lib/cluster/SConscript'])
SConscript(['selfdrive/controls/lib/lateral_mpc/SConscript'])
SConscript(['selfdrive/controls/lib/longitudinal_mpc/SConscript'])
SConscript(['selfdrive/controls/lib/longitudinal_mpc_model/SConscript'])
SConscript(['selfdrive/boardd/SConscript'])
SConscript(['selfdrive/proclogd/SConscript'])
@ -229,5 +245,4 @@ if arch == "aarch64":
SConscript(['selfdrive/locationd/SConscript'])
SConscript(['selfdrive/locationd/kalman/SConscript'])
# TODO: finish cereal, dbcbuilder, MPC
SConscript(['tools/lib/index_log/SConscript'])

Binary file not shown.

7
codecov.yml 100644
View File

@ -0,0 +1,7 @@
coverage:
status:
project:
default:
informational: true
patch: off

View File

@ -135,8 +135,6 @@ def get_network_strength(network_type):
# from SignalStrength.java
def get_lte_level(rsrp, rssnr):
INT_MAX = 2147483647
lvl_rsrp = NetworkStrength.unknown
lvl_rssnr = NetworkStrength.unknown
if rsrp == INT_MAX:
lvl_rsrp = NetworkStrength.unknown
elif rsrp >= -95:
@ -174,7 +172,6 @@ def get_network_strength(network_type):
return lvl
def get_gsm_level(asu):
lvl = NetworkStrength.unknown
if asu <= 2 or asu == 99:
lvl = NetworkStrength.unknown
elif asu >= 12:
@ -232,7 +229,7 @@ def get_network_strength(network_type):
if network_type == NetworkType.none:
return network_strength
if network_type == NetworkType.wifi:
out = subprocess.check_output('dumpsys connectivity', shell=True).decode('ascii')
out = subprocess.check_output('dumpsys connectivity', shell=True).decode('utf-8')
network_strength = NetworkStrength.unknown
for line in out.split('\n'):
signal_str = "SignalStrength: "
@ -251,7 +248,7 @@ def get_network_strength(network_type):
return network_strength
else:
# check cell strength
out = subprocess.check_output('dumpsys telephony.registry', shell=True).decode('ascii')
out = subprocess.check_output('dumpsys telephony.registry', shell=True).decode('utf-8')
for line in out.split('\n'):
if "mSignalStrength" in line:
arr = line.split(' ')

View File

@ -6,5 +6,4 @@ class FirstOrderFilter():
def update(self, x):
self.x = (1. - self.k) * self.x + self.k * x
return self.x

View File

@ -52,7 +52,7 @@ class UnknownKeyName(Exception):
keys = {
"AccessToken": [TxType.PERSISTENT],
"AccessToken": [TxType.CLEAR_ON_MANAGER_START],
"AthenadPid": [TxType.PERSISTENT],
"CalibrationParams": [TxType.PERSISTENT],
"CarParams": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
@ -70,6 +70,7 @@ keys = {
"GithubSshKeys": [TxType.PERSISTENT],
"HasAcceptedTerms": [TxType.PERSISTENT],
"HasCompletedSetup": [TxType.PERSISTENT],
"IsDriverViewEnabled": [TxType.CLEAR_ON_MANAGER_START],
"IsLdwEnabled": [TxType.PERSISTENT],
"IsGeofenceEnabled": [TxType.PERSISTENT],
"IsMetric": [TxType.PERSISTENT],
@ -78,6 +79,7 @@ keys = {
"IsTakingSnapshot": [TxType.CLEAR_ON_MANAGER_START],
"IsUpdateAvailable": [TxType.CLEAR_ON_MANAGER_START],
"IsUploadRawEnabled": [TxType.PERSISTENT],
"LastAthenaPingTime": [TxType.PERSISTENT],
"LastUpdateTime": [TxType.PERSISTENT],
"LimitSetSpeed": [TxType.PERSISTENT],
"LimitSetSpeedNeural": [TxType.PERSISTENT],

View File

@ -39,8 +39,8 @@ class Profiler():
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 IGNORED" % (n, ms*1000.0, ms/self.tot*100))
print("%30s: %9.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("%30s: %9.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))

View File

@ -50,6 +50,9 @@ class FakeSpinner():
def update(self, _):
pass
def close(self):
pass
def __exit__(self, type, value, traceback):
pass

View File

@ -53,7 +53,7 @@ class RunningStat():
class RunningStatFilter():
def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1):
self.raw_stat = RunningStat(raw_priors, max_trackable)
self.raw_stat = RunningStat(raw_priors, -1)
self.filtered_stat = RunningStat(filtered_priors, max_trackable)
def reset(self):

View File

@ -0,0 +1,83 @@
#!/usr/bin/env python3
import os
import time
import subprocess
from common.basedir import BASEDIR
class TextWindow():
def __init__(self, s):
try:
self.text_proc = subprocess.Popen(["./text", s],
stdin=subprocess.PIPE,
cwd=os.path.join(BASEDIR, "selfdrive", "ui", "text"),
close_fds=True)
except OSError:
self.text_proc = None
def get_status(self):
if self.text_proc is not None:
self.text_proc.poll()
return self.text_proc.returncode
return None
def __enter__(self):
return self
def close(self):
if self.text_proc is not None:
self.text_proc.terminate()
self.text_proc = None
def wait_for_exit(self):
while True:
if self.get_status() == 1:
return
time.sleep(0.1)
def __del__(self):
self.close()
def __exit__(self, type, value, traceback):
self.close()
class FakeTextWindow():
def __init__(self, s):
pass
def get_status(self):
return 1
def wait_for_exit(self):
return
def __enter__(self):
return self
def update(self, _):
pass
def __exit__(self, type, value, traceback):
pass
if __name__ == "__main__":
text = """Traceback (most recent call last):
File "./controlsd.py", line 608, in <module>
main()
File "./controlsd.py", line 604, in main
controlsd_thread(sm, pm, logcan)
File "./controlsd.py", line 455, in controlsd_thread
1/0
ZeroDivisionError: division by zero"""
print(text)
with TextWindow(text) as s:
for _ in range(100):
if s.get_status() == 1:
print("Got exit button")
break
time.sleep(0.1)
print("gone")

View File

@ -1,6 +1,5 @@
import numpy as np
import common.transformations.orientation as orient
import math
FULL_FRAME_SIZE = (1164, 874)
W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1]
@ -147,81 +146,3 @@ def pretransform_from_calib(calib):
camera_frame_from_calib_frame = get_camera_frame_from_calib_frame(camera_frame_from_road_frame)
return np.linalg.inv(camera_frame_from_calib_frame)
def transform_img(base_img,
augment_trans=np.array([0,0,0]),
augment_eulers=np.array([0,0,0]),
from_intr=eon_intrinsics,
to_intr=eon_intrinsics,
output_size=None,
pretransform=None,
top_hacks=False,
yuv=False,
alpha=1.0,
beta=0,
blur=0):
import cv2 # pylint: disable=import-error
cv2.setNumThreads(1)
if yuv:
base_img = cv2.cvtColor(base_img, cv2.COLOR_YUV2RGB_I420)
size = base_img.shape[:2]
if not output_size:
output_size = size[::-1]
cy = from_intr[1,2]
def get_M(h=1.22):
quadrangle = np.array([[0, cy + 20],
[size[1]-1, cy + 20],
[0, size[0]-1],
[size[1]-1, size[0]-1]], dtype=np.float32)
quadrangle_norm = np.hstack((normalize(quadrangle, intrinsics=from_intr), np.ones((4,1))))
quadrangle_world = np.column_stack((h*quadrangle_norm[:,0]/quadrangle_norm[:,1],
h*np.ones(4),
h/quadrangle_norm[:,1]))
rot = orient.rot_from_euler(augment_eulers)
to_extrinsics = np.hstack((rot.T, -augment_trans[:,None]))
to_KE = to_intr.dot(to_extrinsics)
warped_quadrangle_full = np.einsum('jk,ik->ij', to_KE, np.hstack((quadrangle_world, np.ones((4,1)))))
warped_quadrangle = np.column_stack((warped_quadrangle_full[:,0]/warped_quadrangle_full[:,2],
warped_quadrangle_full[:,1]/warped_quadrangle_full[:,2])).astype(np.float32)
M = cv2.getPerspectiveTransform(quadrangle, warped_quadrangle.astype(np.float32))
return M
M = get_M()
if pretransform is not None:
M = M.dot(pretransform)
augmented_rgb = cv2.warpPerspective(base_img, M, output_size, borderMode=cv2.BORDER_REPLICATE)
if top_hacks:
cyy = int(math.ceil(to_intr[1,2]))
M = get_M(1000)
if pretransform is not None:
M = M.dot(pretransform)
augmented_rgb[:cyy] = cv2.warpPerspective(base_img, M, (output_size[0], cyy), borderMode=cv2.BORDER_REPLICATE)
# brightness and contrast augment
augmented_rgb = np.clip((float(alpha)*augmented_rgb + beta), 0, 255).astype(np.uint8)
# gaussian blur
if blur > 0:
augmented_rgb = cv2.GaussianBlur(augmented_rgb,(blur*2+1,blur*2+1),cv2.BORDER_DEFAULT)
if yuv:
augmented_img = cv2.cvtColor(augmented_rgb, cv2.COLOR_RGB2YUV_I420)
else:
augmented_img = augmented_rgb
return augmented_img
def yuv_crop(frame, output_size, center=None):
# output_size in camera coordinates so u,v
# center in array coordinates so row, column
import cv2 # pylint: disable=import-error
rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2RGB_I420)
if not center:
center = (rgb.shape[0]/2, rgb.shape[1]/2)
rgb_crop = rgb[center[0] - output_size[1]/2: center[0] + output_size[1]/2,
center[1] - output_size[0]/2: center[1] + output_size[0]/2]
return cv2.cvtColor(rgb_crop, cv2.COLOR_RGB2YUV_I420)

View File

@ -44,24 +44,15 @@ medmodel_intrinsics = np.array(
# BIG model
BIGMODEL_INPUT_SIZE = (864, 288)
BIGMODEL_INPUT_SIZE = (1024, 512)
BIGMODEL_YUV_SIZE = (BIGMODEL_INPUT_SIZE[0], BIGMODEL_INPUT_SIZE[1] * 3 // 2)
bigmodel_zoom = 1.
bigmodel_intrinsics = np.array(
[[ eon_focal_length / bigmodel_zoom, 0. , 0.5 * BIGMODEL_INPUT_SIZE[0]],
[ 0. , eon_focal_length / bigmodel_zoom, 0.2 * BIGMODEL_INPUT_SIZE[1]],
[ 0. , eon_focal_length / bigmodel_zoom, 256+MEDMODEL_CY],
[ 0. , 0. , 1.]])
bigmodel_border = np.array([
[0,0,1],
[BIGMODEL_INPUT_SIZE[0], 0, 1],
[BIGMODEL_INPUT_SIZE[0], BIGMODEL_INPUT_SIZE[1], 1],
[0, BIGMODEL_INPUT_SIZE[1], 1],
])
model_frame_from_road_frame = np.dot(model_intrinsics,
get_view_frame_from_road_frame(0, 0, 0, model_height))
@ -72,6 +63,7 @@ medmodel_frame_from_road_frame = np.dot(medmodel_intrinsics,
get_view_frame_from_road_frame(0, 0, 0, model_height))
model_frame_from_bigmodel_frame = np.dot(model_intrinsics, np.linalg.inv(bigmodel_intrinsics))
medmodel_frame_from_bigmodel_frame = np.dot(medmodel_intrinsics, np.linalg.inv(bigmodel_intrinsics))
# 'camera from model camera'
def get_model_height_transform(camera_frame_from_road_frame, height):

45
common/xattr.py 100644
View File

@ -0,0 +1,45 @@
import os
from cffi import FFI
# Workaround for the EON/termux build of Python having os.*xattr removed.
ffi = FFI()
ffi.cdef("""
int setxattr(const char *path, const char *name, const void *value, size_t size, int flags);
ssize_t getxattr(const char *path, const char *name, void *value, size_t size);
ssize_t listxattr(const char *path, char *list, size_t size);
int removexattr(const char *path, const char *name);
""")
libc = ffi.dlopen(None)
def setxattr(path, name, value, flags=0):
path = path.encode()
name = name.encode()
if libc.setxattr(path, name, value, len(value), flags) == -1:
raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: setxattr({path}, {name}, {value}, {flags})")
def getxattr(path, name, size=128):
path = path.encode()
name = name.encode()
value = ffi.new(f"char[{size}]")
l = libc.getxattr(path, name, value, size)
if l == -1:
# errno 61 means attribute hasn't been set
if ffi.errno == 61:
return None
raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: getxattr({path}, {name}, {size})")
return ffi.buffer(value)[:l]
def listxattr(path, size=128):
path = path.encode()
attrs = ffi.new(f"char[{size}]")
l = libc.listxattr(path, attrs, size)
if l == -1:
raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: listxattr({path}, {size})")
# attrs is b'\0' delimited values (so chop off trailing empty item)
return [a.decode() for a in ffi.buffer(attrs)[:l].split(b"\0")[0:-1]]
def removexattr(path, name):
path = path.encode()
name = name.encode()
if libc.removexattr(path, name) == -1:
raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: removexattr({path}, {name})")

View File

@ -62,6 +62,11 @@ function launch {
echo 0-3 > /dev/cpuset/foreground/cpus
echo 0-3 > /dev/cpuset/android/cpus
# change interrupt affinity
echo 3 > /proc/irq/6/smp_affinity_list # MDSS
echo 1 > /proc/irq/78/smp_affinity_list # Modem, can potentially lock up
echo 2 > /proc/irq/733/smp_affinity_list # USB
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Remove old NEOS update file

14
lgtm.yml 100644
View File

@ -0,0 +1,14 @@
path_classifiers:
library:
- external
- phonelibs
- pyextra
- tools/lib/mkvparse
extraction:
cpp:
after_prepare:
- "pip3 install jinja2 pyyaml cython pycapnp numpy sympy tqdm cffi logentries zmq"
- "export PATH=$PWD/external/bin:$PATH"
index:
build_command: "python3 $(which scons)"

Binary file not shown.

Binary file not shown.

View File

@ -4,9 +4,6 @@ def static_library(lib_dir, header_dir):
env.Append(LIBPATH=[Dir(lib_dir)])
env.Append(CPPPATH=[Dir(header_dir)])
env.Library('json', ['json/src/json.c'])
env.Append(CPPPATH=[Dir('json/src')])
env.Library('json11', ['json11/json11.cpp'])
env.Append(CPPPATH=[Dir('json11')])

File diff suppressed because it is too large Load Diff

View File

@ -1,117 +0,0 @@
/*
Copyright (C) 2011 Joseph A. Adams (joeyadams3.14159@gmail.com)
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 Software.
THE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef CCAN_JSON_H
#define CCAN_JSON_H
#include <stdbool.h>
#include <stddef.h>
typedef enum {
JSON_NULL,
JSON_BOOL,
JSON_STRING,
JSON_NUMBER,
JSON_ARRAY,
JSON_OBJECT,
} JsonTag;
typedef struct JsonNode JsonNode;
struct JsonNode
{
/* only if parent is an object or array (NULL otherwise) */
JsonNode *parent;
JsonNode *prev, *next;
/* only if parent is an object (NULL otherwise) */
char *key; /* Must be valid UTF-8. */
JsonTag tag;
union {
/* JSON_BOOL */
bool bool_;
/* JSON_STRING */
char *string_; /* Must be valid UTF-8. */
/* JSON_NUMBER */
double number_;
/* JSON_ARRAY */
/* JSON_OBJECT */
struct {
JsonNode *head, *tail;
} children;
};
};
/*** Encoding, decoding, and validation ***/
JsonNode *json_decode (const char *json);
char *json_encode (const JsonNode *node);
char *json_encode_string (const char *str);
char *json_stringify (const JsonNode *node, const char *space);
void json_delete (JsonNode *node);
bool json_validate (const char *json);
/*** Lookup and traversal ***/
JsonNode *json_find_element (JsonNode *array, int index);
JsonNode *json_find_member (JsonNode *object, const char *key);
JsonNode *json_first_child (const JsonNode *node);
#define json_foreach(i, object_or_array) \
for ((i) = json_first_child(object_or_array); \
(i) != NULL; \
(i) = (i)->next)
/*** Construction and manipulation ***/
JsonNode *json_mknull(void);
JsonNode *json_mkbool(bool b);
JsonNode *json_mkstring(const char *s);
JsonNode *json_mknumber(double n);
JsonNode *json_mkarray(void);
JsonNode *json_mkobject(void);
void json_append_element(JsonNode *array, JsonNode *element);
void json_prepend_element(JsonNode *array, JsonNode *element);
void json_append_member(JsonNode *object, const char *key, JsonNode *value);
void json_prepend_member(JsonNode *object, const char *key, JsonNode *value);
void json_remove_from_parent(JsonNode *node);
/*** Debugging ***/
/*
* Look for structure and encoding problems in a JsonNode or its descendents.
*
* If a problem is detected, return false, writing a description of the problem
* to errmsg (unless errmsg is NULL).
*/
bool json_check(const JsonNode *node, char errmsg[256]);
#endif

View File

@ -166,7 +166,7 @@ struct ion_flush_data {
struct ion_prefetch_regions {
unsigned int vmid;
size_t __user *sizes;
size_t *sizes;
unsigned int nr_sizes;
};
@ -174,7 +174,7 @@ 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;
struct ion_prefetch_regions *regions;
unsigned int nr_regions;
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
aarch64-android-clang6.0

Binary file not shown.

View File

@ -32,7 +32,8 @@ public:
DiagLogMask(""),
LogFileDirectory("diaglogs"),
LogFileName("DiagLog"),
LogFileRotateCount(20)
LogFileRotateCount(20),
LogFileReplace(true)
{
// Solves the empty string problem with multiple std libs
DiagLogMask.reserve(1);
@ -65,6 +66,13 @@ public:
/// any existing log file that may exist.
/// Default value is 20
uint32_t LogFileRotateCount;
/// @brief
///
/// If the log file already exists, control whether it will be replaced
/// (existing contents truncated), or appended.
/// Default value is true
bool LogFileReplace;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */

View File

@ -1,6 +1,6 @@
//=============================================================================
//
// Copyright (c) 2015 Qualcomm Technologies, Inc.
// Copyright (c) 2015,2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
@ -43,7 +43,15 @@ struct ZDL_EXPORT DlcRecord
: name(std::move(other.name))
, data(std::move(other.data))
{}
DlcRecord(const std::string& new_name)
: name(new_name)
, data()
{
if(name.empty())
{
name.reserve(1);
}
}
DlcRecord(const DlcRecord&) = delete;
};
@ -63,9 +71,9 @@ class ZDL_EXPORT IDlContainer
public:
/**
* Initializes a container from a container archive file.
*
*
* @param[in] filename Container archive file path.
*
*
* @return A pointer to the initialized container
*/
ZDL_EXPORT static std::unique_ptr<IDlContainer>
@ -83,10 +91,10 @@ public:
/**
* Initializes a container from a byte buffer.
*
* @param[in] buffer Byte buffer holding the contents of an archive
*
* @param[in] buffer Byte buffer holding the contents of an archive
* file.
*
*
* @return A pointer to the initialized container
*/
ZDL_EXPORT static std::unique_ptr<IDlContainer>
@ -94,12 +102,12 @@ public:
/**
* Initializes a container from a byte buffer.
*
* @param[in] buffer Byte buffer holding the contents of an archive
*
* @param[in] buffer Byte buffer holding the contents of an archive
* file.
*
* @param[in] size Size of the byte buffer.
*
*
* @return A pointer to the initialized container
*/
ZDL_EXPORT static std::unique_ptr<IDlContainer>
@ -110,8 +118,8 @@ public:
/**
* Get the record catalog for a container.
*
* @param[out] catalog Buffer that will hold the record names on
*
* @param[out] catalog Buffer that will hold the record names on
* return.
*/
virtual void getCatalog(std::set<std::string> &catalog) const = 0;
@ -126,7 +134,7 @@ public:
/**
* Get a record from a container by name.
*
*
* @param[in] name Name of the record to fetch.
* @param[out] record The passed in record will be populated with the
* record data on return. Note that the caller
@ -146,6 +154,34 @@ public:
*/
virtual void getRecord(const zdl::DlSystem::String &name, DlcRecord &record) const = 0;
/**
* Save the container to an archive on disk. This function will save the
* container if the filename is different from the file that it was opened
* from, or if at least one record was modified since the container was
* opened.
*
* It will truncate any existing file at the target path.
*
* @param filename Container archive file path.
*
* @return indication of success/failure
*/
virtual bool save(const std::string &filename) = 0;
/**
* Save the container to an archive on disk. This function will save the
* container if the filename is different from the file that it was opened
* from, or if at least one record was modified since the container was
* opened.
*
* It will truncate any existing file at the target path.
*
* @param filename Container archive file path.
*
* @return indication of success/failure
*/
virtual bool save (const zdl::DlSystem::String &filename) = 0;
virtual ~IDlContainer() {}
};

View File

@ -1,6 +1,6 @@
//==============================================================================
//
// Copyright (c) 2014-2018 Qualcomm Technologies, Inc.
// Copyright (c) 2014-2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
@ -43,6 +43,12 @@ enum class Runtime_t
/// Math: float 16bit
GPU_FLOAT16 = 3,
/// Run the processing on Snapdragon AIX+HVX.
/// Data: 8bit fixed point Tensorflow style format
/// Math: 8bit fixed point Tensorflow style format
AIP_FIXED8_TF = 5,
AIP_FIXED_TF = AIP_FIXED8_TF,
/// Default legacy enum to retain backward compatibility.
/// CPU = CPU_FLOAT32
CPU = CPU_FLOAT32,
@ -53,7 +59,23 @@ enum class Runtime_t
/// Default legacy enum to retain backward compatibility.
/// DSP = DSP_FIXED8_TF
DSP = DSP_FIXED8_TF
DSP = DSP_FIXED8_TF,
/// Special value indicating the property is unset.
UNSET = -1
};
/**
* Enumeration of runtime available check options.
*/
enum class RuntimeCheckOption_t
{
/// Perform standard runtime available check
DEFAULT = 0,
/// Perform standard runtime available check
NORMAL_CHECK = 0,
/// Perform basic runtime available check, may be runtime specific
BASIC_CHECK = 1,
};
/**
@ -68,17 +90,47 @@ enum class PerformanceProfile_t
BALANCED = 0,
/// Run in high performance mode
HIGH_PERFORMANCE,
HIGH_PERFORMANCE = 1,
/// Run in a power sensitive mode, at the expense of performance.
POWER_SAVER,
POWER_SAVER = 2,
/// Use system settings. SNPE makes no calls to any performance related APIs.
SYSTEM_SETTINGS,
SYSTEM_SETTINGS = 3,
/// Run in sustained high performance mode
SUSTAINED_HIGH_PERFORMANCE
SUSTAINED_HIGH_PERFORMANCE = 4,
/// Run in burst mode
BURST = 5,
/// Run in lower clock than POWER_SAVER, at the expense of performance.
LOW_POWER_SAVER = 6,
/// Run in higher clock and provides better performance than POWER_SAVER.
HIGH_POWER_SAVER = 7,
/// Run in lower balanced mode
LOW_BALANCED = 8,
};
/**
* Enumeration of various profilngLevels that can be requested.
*/
enum class ProfilingLevel_t
{
/// No profiling.
/// Collects no runtime stats in the DiagLog
OFF = 0,
/// Basic profiling
/// Collects some runtime stats in the DiagLog
BASIC = 1,
/// Detailed profiling
/// Collects more runtime stats in the DiagLog
/// Performance may be impacted
DETAILED = 2
};
/**
@ -90,10 +142,10 @@ enum class ExecutionPriorityHint_t
NORMAL = 0,
/// Higher than normal priority
HIGH,
HIGH = 1,
/// Lower priority
LOW
LOW = 2
};
@ -110,34 +162,34 @@ enum class ImageEncoding_t
/// The RGB format consists of 3 bytes per pixel: one byte for
/// Red, one for Green, and one for Blue. The byte ordering is
/// endian independent and is always in RGB byte order.
RGB,
RGB = 1,
/// The ARGB32 format consists of 4 bytes per pixel: one byte for
/// Red, one for Green, one for Blue, and one for the alpha channel.
/// The alpha channel is ignored. The byte ordering depends on the
/// underlying CPU. For little endian CPUs, the byte order is BGRA.
/// For big endian CPUs, the byte order is ARGB.
ARGB32,
ARGB32 = 2,
/// The RGBA format consists of 4 bytes per pixel: one byte for
/// Red, one for Green, one for Blue, and one for the alpha channel.
/// The alpha channel is ignored. The byte ordering is endian independent
/// and is always in RGBA byte order.
RGBA,
RGBA = 3,
/// The GRAYSCALE format is for 8-bit grayscale.
GRAYSCALE,
GRAYSCALE = 4,
/// NV21 is the Android version of YUV. The Chrominance is down
/// sampled and has a subsampling ratio of 4:2:0. Note that this
/// image format has 3 channels, but the U and V channels
/// are subsampled. For every four Y pixels there is one U and one V pixel. @newpage
NV21,
NV21 = 5,
/// The BGR format consists of 3 bytes per pixel: one byte for
/// Red, one for Green and one for Blue. The byte ordering is
/// endian independent and is always BGR byte order.
BGR
BGR = 6
};
}} // namespaces end

View File

@ -1,6 +1,6 @@
//==============================================================================
//
// Copyright (c) 2016-18 Qualcomm Technologies, Inc.
// Copyright (c) 2016-2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
@ -34,6 +34,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
SNPE_CONFIG_WRONG_INPUT_NAME = 105,
SNPE_CONFIG_INCORRECT_INPUT_DIMENSIONS = 106,
SNPE_CONFIG_DIMENSIONS_MODIFICATION_NOT_SUPPORTED = 107,
SNPE_CONFIG_BOTH_OUTPUT_LAYER_TENSOR_NAMES_SET = 108,
SNPE_CONFIG_NNCONFIG_ONLY_TENSOR_SUPPORTED = 120,
SNPE_CONFIG_NNCONFIG_ONLY_USER_BUFFER_SUPPORTED = 121,
@ -56,8 +57,11 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
SNPE_DLSYSTEM_BUFFER_MANAGER_MISSING = 214,
SNPE_DLSYSTEM_RUNTIME_BUFFER_SOURCE_UNSUPPORTED = 215,
SNPE_DLSYSTEM_BUFFER_CAST_FAILED = 216,
SNPE_DLSYSTEM_WRONG_TRANSITION_TYPE = 217,
SNPE_DLSYSTEM_LAYER_ALREADY_REGISTERED = 218,
SNPE_DLSYSTEM_BUFFERENCODING_UNKNOWN = 240,
SNPE_DLSYSTEM_BUFFER_INVALID_PARAM = 241,
// DlContainer errors
SNPE_DLCONTAINER_MODEL_PARSING_FAILED = 300,
@ -95,6 +99,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
SNPE_CPU_LAYER_PARAM_COMBINATION_INVALID = 603,
SNPE_CPU_BUFFER_NOT_FOUND = 604,
SNPE_CPU_NETWORK_NOT_SUPPORTED = 605,
SNPE_CPU_UDO_OPERATION_FAILED = 606,
// CPU fixed-point runtime errors
SNPE_CPU_FXP_LAYER_NOT_SUPPORTED = 700,
@ -119,7 +124,8 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
SNPE_GPU_LAYER_PROXY_ERROR = 814,
SNPE_GPU_BUFFER_IN_USE = 815,
SNPE_GPU_BUFFER_MODIFICATION_ERROR = 816,
SNPE_GPU_DATA_ARRANGEMENT_INVALID = 817,
SNPE_GPU_UDO_OPERATION_FAILED = 818,
// DSP runtime errors
SNPE_DSP_LAYER_NOT_SUPPORTED = 900,
SNPE_DSP_LAYER_PARAM_NOT_SUPPORTED = 901,
@ -132,6 +138,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
SNPE_DSP_RUNTIME_COMMUNICATION_ERROR = 908,
SNPE_DSP_RUNTIME_INVALID_PARAM_ERROR = 909,
SNPE_DSP_RUNTIME_SYSTEM_ERROR = 910,
SNPE_DSP_RUNTIME_CRASHED_ERROR = 911,
// Model validataion errors
SNPE_MODEL_VALIDATION_LAYER_NOT_SUPPORTED = 1000,
@ -143,6 +150,8 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
SNPE_MODEL_VALIDATION_INVALID_CONSTRAINT = 1006,
SNPE_MODEL_VALIDATION_MISSING_BUFFER = 1007,
SNPE_MODEL_VALIDATION_BUFFER_REUSE_NOT_SUPPORTED = 1008,
SNPE_MODEL_VALIDATION_LAYER_COULD_NOT_BE_ASSIGNED = 1009,
SNPE_MODEL_VALIDATION_UDO_LAYER_FAILED = 1010,
// UDL errors
SNPE_UDL_LAYER_EMPTY_UDL_NETWORK = 1100,
@ -151,6 +160,9 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
SNPE_UDL_LAYER_SETUP_FAILED = 1103,
SNPE_UDL_EXECUTE_FAILED = 1104,
SNPE_UDL_BUNDLE_INVALID = 1105,
SNPE_UDO_REGISTRATION_FAILED = 1106,
SNPE_UDO_GET_PACKAGE_FAILED = 1107,
SNPE_UDO_GET_IMPLEMENTATION_FAILED = 1108,
// Dependent library errors
SNPE_STD_LIBRARY_ERROR = 1200,
@ -161,6 +173,26 @@ enum class ZDL_EXPORT ErrorCode : uint32_t {
// Storage Errors
SNPE_STORAGE_INVALID_KERNEL_REPO = 1300,
// AIP runtime errors
SNPE_AIP_LAYER_NOT_SUPPORTED = 1400,
SNPE_AIP_LAYER_PARAM_NOT_SUPPORTED = 1401,
SNPE_AIP_LAYER_PARAM_INVALID = 1402,
SNPE_AIP_LAYER_PARAM_COMBINATION_INVALID = 1403,
SNPE_AIP_STUB_NOT_PRESENT = 1404,
SNPE_AIP_LAYER_NAME_TRUNCATED = 1405,
SNPE_AIP_LAYER_INPUT_BUFFER_NAME_TRUNCATED = 1406,
SNPE_AIP_LAYER_OUTPUT_BUFFER_NAME_TRUNCATED = 1407,
SNPE_AIP_RUNTIME_COMMUNICATION_ERROR = 1408,
SNPE_AIP_RUNTIME_INVALID_PARAM_ERROR = 1409,
SNPE_AIP_RUNTIME_SYSTEM_ERROR = 1410,
SNPE_AIP_RUNTIME_TENSOR_MISSING = 1411,
SNPE_AIP_RUNTIME_TENSOR_SHAPE_MISMATCH = 1412,
SNPE_AIP_RUNTIME_BAD_AIX_RECORD = 1413,
// DlCaching errors
SNPE_DLCACHING_INVALID_METADATA = 1500,
SNPE_DLCACHING_INVALID_INITBLOB = 1501
};
@ -187,6 +219,11 @@ ZDL_EXPORT ErrorCode getLastErrorCode();
*/
ZDL_EXPORT const char* getLastErrorString();
/**
* Returns the info string of the last error encountered.
*/
ZDL_EXPORT const char* getLastInfoString();
/**
* Returns the uint32_t representation of the error code enum.
*

View File

@ -35,10 +35,10 @@ template <typename T>
class ZDL_EXPORT Optional final {
public:
enum class LIFECYCLE {
NONE,
REFERENCE_OWNED,
POINTER_OWNED,
POINTER_NOT_OWNED
NONE = 0,
REFERENCE_OWNED = 1,
POINTER_OWNED = 2,
POINTER_NOT_OWNED = 3
};
struct ReferenceCount {

View File

@ -1,6 +1,6 @@
//==============================================================================
//
// Copyright (c) 2017 Qualcomm Technologies, Inc.
// Copyright (c) 2017-2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
@ -21,7 +21,6 @@ namespace zdl {
namespace zdl {
namespace DlSystem {
/**
* @brief IBufferAttributes returns a buffer's dimension and alignment
* requirements, along with info on its encoding type
@ -65,6 +64,15 @@ public:
*/
virtual const TensorShape getAlignments() const noexcept = 0;
/**
* @brief Gets the buffer encoding returned from the network responsible
* for generating this buffer. Depending on the encoding type, this will
* be an instance of an encoding type specific derived class.
*
* @return Derived user buffer encoding object.
*/
virtual zdl::DlSystem::UserBufferEncoding* getEncoding() const noexcept = 0;
virtual ~IBufferAttributes() {}
};

View File

@ -1,6 +1,6 @@
//==============================================================================
//
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// Copyright (c) 2017-2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
@ -11,6 +11,7 @@
#include "TensorShape.hpp"
#include "ZdlExportDefine.hpp"
#include <math.h>
namespace zdl {
namespace DlSystem {
@ -44,7 +45,10 @@ public:
UNSIGNED8BIT = 2,
/// Each element is presented by an 8-bit quantized value.
TF8 = 10
TF8 = 10,
/// Each element is presented by an 16-bit quantized value.
TF16 = 11
};
/**
@ -147,6 +151,7 @@ public:
* An encoding type where each element is represented by tf8, which is an
* 8-bit quantizd value, which has an exact representation of 0.0
*/
class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingUnsigned8Bit {
public:
UserBufferEncodingTf8() = delete;
@ -155,60 +160,72 @@ public:
m_StepExactly0(stepFor0),
m_QuantizedStepSize(stepSize) {};
/**
/**
* @brief Sets the step value that represents 0
*
* @param[in] stepExactly0 The step value that represents 0
*
*/
void setStepExactly0(const unsigned char stepExactly0) {
m_StepExactly0 = stepExactly0;
}
/**
/**
* @brief Sets the float value that each step represents
*
* @param[in] quantizedStepSize The float value of each step size
*
*/
void setQuantizedStepSize(const float quantizedStepSize) {
m_QuantizedStepSize = quantizedStepSize;
}
/**
/**
* @brief Retrieves the step that represents 0.0
*
* @return Step value
*/
unsigned char getStepExactly0() const {
return m_StepExactly0;
}
/**
/**
* Calculates the minimum floating point value that
* can be represented with this encoding.
*
* @return Minimum representable floating point value
*/
float getMin() const {
return m_QuantizedStepSize * (0 - m_StepExactly0);
}
/**
/**
* Calculates the maximum floating point value that
* can be represented with this encoding.
*
* @return Maximum representable floating point value
*/
float getMax() const {
return m_QuantizedStepSize * (255 - m_StepExactly0);
}
/**
/**
* @brief Retrieves the step size
*
* @return Step size
*/
float getQuantizedStepSize() const {
return m_QuantizedStepSize;
}
@ -219,6 +236,84 @@ private:
float m_QuantizedStepSize;
};
class ZDL_EXPORT UserBufferEncodingTfN : public UserBufferEncoding {
public:
UserBufferEncodingTfN() = delete;
UserBufferEncodingTfN(uint64_t stepFor0, float stepSize, uint8_t bWidth=8):
UserBufferEncoding(getTypeFromWidth(bWidth)),
bitWidth(bWidth),
m_StepExactly0(stepFor0),
m_QuantizedStepSize(stepSize){};
size_t getElementSize() const noexcept override;
/**
* @brief Sets the step value that represents 0
*
* @param[in] stepExactly0 The step value that represents 0
*
*/
void setStepExactly0(uint64_t stepExactly0) {
m_StepExactly0 = stepExactly0;
}
/**
* @brief Sets the float value that each step represents
*
* @param[in] quantizedStepSize The float value of each step size
*
*/
void setQuantizedStepSize(const float quantizedStepSize) {
m_QuantizedStepSize = quantizedStepSize;
}
/**
* @brief Retrieves the step that represents 0.0
*
* @return Step value
*/
uint64_t getStepExactly0() const {
return m_StepExactly0;
}
/**
* Calculates the minimum floating point value that
* can be represented with this encoding.
*
* @return Minimum representable floating point value
*/
float getMin() const {
return m_QuantizedStepSize * (0 - (double)m_StepExactly0);
}
/**
* Calculates the maximum floating point value that
* can be represented with this encoding.
*
* @return Maximum representable floating point value
*/
float getMax() const{
return m_QuantizedStepSize * (pow(2,bitWidth)-1 - (double)m_StepExactly0);
};
/**
* @brief Retrieves the step size
*
* @return Step size
*/
float getQuantizedStepSize() const {
return m_QuantizedStepSize;
}
ElementType_t getTypeFromWidth(uint8_t width);
uint8_t bitWidth;
private:
uint64_t m_StepExactly0;
float m_QuantizedStepSize;
};
/**
* @brief UserBuffer contains a pointer and info on how to walk it and interpret its content.
*/
@ -243,6 +338,24 @@ public:
*/
virtual size_t getSize() const = 0;
/**
* @brief Retrieves the size of the inference data in the buffer, in bytes.
*
* The inference results from a dynamic-sized model may not be exactly the same size
* as the UserBuffer provided to SNPE. This function can be used to get the amount
* of output inference data, which may be less or greater than the size of the UserBuffer.
*
* If the inference results fit in the UserBuffer, getOutputSize() would be less than
* or equal to getSize(). But if the inference results were more than the capacity of
* the provided UserBuffer, the results would be truncated to fit the UserBuffer. But,
* getOutputSize() would be greater than getSize(), which indicates a bigger buffer
* needs to be provided to SNPE to hold all of the inference results.
*
* @return Size required for the buffer to hold all inference results, which can be less
* or more than the size of the buffer, in bytes.
*/
virtual size_t getOutputSize() const = 0;
/**
* @brief Changes the underlying memory that backs the UserBuffer.
*

View File

@ -10,6 +10,7 @@
#define _DL_SYSTEM_PLATFORM_CONFIG_HPP_
#include "DlSystem/ZdlExportDefine.hpp"
#include <string>
namespace zdl{
namespace DlSystem
@ -92,7 +93,8 @@ public:
PlatformConfigInfo(){};
};
PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN) {};
PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN),
m_PlatformOptions("") {};
/**
* @brief Retrieves the platform type
@ -156,9 +158,42 @@ public:
return false;
}
/**
* @brief Sets the platform options
*
* @param[in] options Options as a string in the form of "keyword:options"
*
* @return True if options are pass validation; otherwise false. If false, the options are not updated.
*/
bool setPlatformOptions(std::string options) {
std::string oldOptions = m_PlatformOptions;
m_PlatformOptions = options;
if (isOptionsValid()) {
return true;
} else {
m_PlatformOptions = oldOptions;
return false;
}
}
/**
* @brief Indicates whther the plaform configuration is valid.
*
* @return True if the platform configuration is valid; false otherwise.
*/
bool isOptionsValid() const;
/**
* @brief Gets the platform options
*
* @return Options as a string
*/
std::string getPlatformOptions() const { return m_PlatformOptions; }
private:
PlatformType_t m_PlatformType;
PlatformConfigInfo m_PlatformConfigInfo;
std::string m_PlatformOptions;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */

View File

@ -0,0 +1,154 @@
//=============================================================================
//
// Copyright (c) 2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include "ZdlExportDefine.hpp"
#include "DlSystem/DlEnums.hpp"
#include "DlSystem/StringList.hpp"
#include <cstddef>
#include <memory>
#ifndef DL_SYSTEM_RUNTIME_LIST_HPP
#define DL_SYSTEM_RUNTIME_LIST_HPP
namespace DlSystem
{
// Forward declaration of Runtime List implementation.
class RuntimeListImpl;
}
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A class representing list of runtimes
*/
class ZDL_EXPORT RuntimeList final
{
public:
/**
* @brief .
*
* Creates a new runtime list
*
*/
RuntimeList();
/**
* @brief .
*
* copy constructor.
* @param[in] other object to copy.
*/
RuntimeList(const RuntimeList& other);
/**
* @brief .
*
* constructor with single Runtime_t object
* @param[in] Runtime_t object
*/
RuntimeList(const zdl::DlSystem::Runtime_t& runtime);
/**
* @brief .
*
* assignment operator.
*/
RuntimeList& operator=(const RuntimeList& other);
/**
* @brief .
*
* subscript operator.
*/
Runtime_t& operator[](size_t index);
/**
* @brief Adds runtime to the end of the runtime list
* order of precedence is former followed by latter entry
*
* @param[in] runtime to add
*
* Ruturns false If the runtime already exists
*/
bool add(const zdl::DlSystem::Runtime_t& runtime);
/**
* @brief Removes the runtime from the list
*
* @param[in] runtime to be removed
*
* @note If the runtime is not found, nothing is done.
*/
void remove(const zdl::DlSystem::Runtime_t runtime) noexcept;
/**
* @brief Returns the number of runtimes in the list
*/
size_t size() const noexcept;
/**
* @brief Returns true if the list is empty
*/
bool empty() const noexcept;
/**
* @brief .
*
* Removes all runtime from the list
*/
void clear() noexcept;
/**
* @brief .
*
* Returns a StringList of names from the runtime list in
* order of precedence
*/
zdl::DlSystem::StringList getRuntimeListNames() const;
/**
* @brief .
*
* @param[in] runtime string
* Returns a Runtime enum corresponding to the in param string
*
*/
static zdl::DlSystem::Runtime_t stringToRuntime(const char* runtimeStr);
/**
* @brief .
*
* @param[in] runtime
* Returns a string corresponding to the in param runtime enum
*
*/
static const char* runtimeToString(const zdl::DlSystem::Runtime_t runtime);
~RuntimeList();
private:
void deepCopy(const RuntimeList &other);
std::unique_ptr<::DlSystem::RuntimeListImpl> m_RuntimeListImpl;
};
} // DlSystem namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // DL_SYSTEM_RUNTIME_LIST_HPP

View File

@ -0,0 +1,101 @@
//==============================================================================
//
// Copyright (c) 2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef PSNPE_APPLICATIONBUFFERMAP_HPP
#define PSNPE_APPLICATIONBUFFERMAP_HPP
#include <vector>
#include <string>
#include <unordered_map>
#include "DlSystem/UserBufferMap.hpp"
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl
{
namespace PSNPE
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A class representing the UserBufferMap of Input and Output asynchronous mode.
*/
class ZDL_EXPORT ApplicationBufferMap final
{
public:
/**
* @brief Adds a name and the corresponding buffer
* to the map
*
* @param[in] name The name of the UserBuffer
* @param[in] buffer The vector of the uint8_t data
*
* @note If a UserBuffer with the same name already exists, the new
* UserBuffer pointer would be updated.
*/
void add(const char* name, std::vector<uint8_t>& buff) noexcept;
void add(const char* name, std::vector<float>& buff) noexcept;
/**
* @brief Removes a mapping of one UserBuffer and its name by its name
*
* @param[in] name The name of UserBuffer to be removed
*
* @note If no UserBuffer with the specified name is found, nothing
* is done.
*/
void remove(const char* name) noexcept;
/**
* @brief Returns the number of UserBuffers in the map
*/
size_t size() const noexcept;
/**
* @brief .
*
* Removes all UserBuffers from the map
*/
void clear() noexcept;
/**
* @brief Returns the UserBuffer given its name.
*
* @param[in] name The name of the UserBuffer to get.
*
* @return nullptr if no UserBuffer with the specified name is
* found; otherwise, a valid pointer to the UserBuffer.
*/
const std::vector<uint8_t>& getUserBuffer(const char* name) const;
const std::vector<uint8_t>& operator[](const char* name) const;
/**
* @brief .
*
* Returns the names of all UserAsyncBufferMap
*
* @return A list of UserBuffer names.
*/
zdl::DlSystem::StringList getUserBufferNames() const;
const std::unordered_map<std::string, std::vector<uint8_t>>& getUserBuffer() const;
explicit ApplicationBufferMap();
~ApplicationBufferMap();
explicit ApplicationBufferMap(
const std::unordered_map<std::string, std::vector<uint8_t>> buffer);
private:
std::unordered_map<std::string, std::vector<uint8_t>> m_UserMap;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // namespace PSNPE
} // namespace zdl
#endif // PSNPE_APPLICATIONBUFFERMAP_HPP

View File

@ -0,0 +1,174 @@
// =============================================================================
//
// Copyright (c) 2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
// =============================================================================
#ifndef PSNPE_HPP
#define PSNPE_HPP
#include <cstdlib>
#include <unordered_map>
#include <functional>
#include "SNPE/SNPE.hpp"
#include "DlSystem/UserBufferMap.hpp"
#include "DlContainer/IDlContainer.hpp"
#include "DlSystem/DlEnums.hpp"
#include "DlSystem/ZdlExportDefine.hpp"
#include "UserBufferList.hpp"
#include "RuntimeConfigList.hpp"
#include "ApplicationBufferMap.hpp"
namespace zdl
{
namespace PSNPE
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
*@ brief build snpe instance in serial or parallel
*
*/
enum ZDL_EXPORT BuildMode {
SERIAL = 0,
PARALLEL = 1
};
/**
* @brief Input and output transmission mode
*/
enum ZDL_EXPORT InputOutputTransmissionMode
{
sync = 0,
outputAsync = 1,
inputOutputAsync = 2
};
/**
* @brief A structure representing parameters of callback function of Async Output mode
*/
struct ZDL_EXPORT OutputAsyncCallbackParam
{
size_t dataIndex;
bool executeStatus;
OutputAsyncCallbackParam(size_t _index,bool _status)
: dataIndex(_index),executeStatus(_status){};
};
/**
* @brief A structure representing parameters of callback function of Async Input/Output mode
*/
struct ZDL_EXPORT InputOutputAsyncCallbackParam
{
size_t dataIndex;
const ApplicationBufferMap& outputMap;
bool executeStatus;
InputOutputAsyncCallbackParam(size_t _index, const ApplicationBufferMap& output_map,bool _status)
: dataIndex(_index)
, outputMap(output_map)
,executeStatus(_status){
};
};
using OutputAsyncCallbackFunc = std::function<void(OutputAsyncCallbackParam)>;
using InputOutputAsyncCallbackFunc = std::function<void(InputOutputAsyncCallbackParam)>;
/**
* @brief .
*
* A structure BulkSNPE configuration
*/
struct ZDL_EXPORT BuildConfig final
{
BuildMode buildMode = BuildMode::SERIAL;
zdl::DlContainer::IDlContainer* container;
zdl::DlSystem::StringList outputBufferNames;
RuntimeConfigList runtimeConfigList;
OutputAsyncCallbackFunc outputCallback;
InputOutputAsyncCallbackFunc inputOutputCallback;
InputOutputTransmissionMode inputOutputTransmissionMode = InputOutputTransmissionMode::sync;
};
/**
* @brief .
*
* The class for executing SNPE instances in parallel.
*/
class ZDL_EXPORT PSNPE final
{
public:
~PSNPE();
explicit PSNPE() noexcept :m_TransmissionMode(InputOutputTransmissionMode::sync){};
/**
* @brief Build snpe instances.
*
*/
bool build(BuildConfig& buildConfig) noexcept;
/**
* @brief Execute snpe instances in Async Output mode and Sync mode
*
* @param[in] inputBufferList A list of user buffers that contains the input data
*
* @param[in,out] outputBufferList A list of user buffers that will hold the output data
*
*/
bool execute(UserBufferList& inputBufferList, UserBufferList& outputBufferList) noexcept;
/**
* @brief Execute snpe instances in Async Input/Output mode
*
* @param[in]inputMap A map of input buffers that contains input data. The names of buffers
* need to be matched with names retrived through getInputTensorNames()
*
* @param dataIndex Index of the input data
*
* @param isTF8buff Whether prefer to using 8 bit quantized element for inference
*
* @return True if executed successfully; flase, otherwise.
*/
bool executeInputOutputAsync(const ApplicationBufferMap& inputMap, size_t dataIndex, bool isTF8buff) noexcept;
/**
* @brief Returns the input layer names of the network.
*
* @return StringList which contains the input layer names
*/
const zdl::DlSystem::StringList getInputTensorNames() const noexcept;
/**
* @brief Returns the output layer names of the network.
*
* @return StringList which contains the output layer names
*/
const zdl::DlSystem::StringList getOutputTensorNames() const noexcept;
/**
* @brief Returns the input tensor dimensions of the network.
*
* @return TensorShape which contains the dimensions.
*/
const zdl::DlSystem::TensorShape getInputDimensions() const noexcept;
/**
* @brief Returns attributes of buffers.
*
* @see zdl::SNPE
*
* @return BufferAttributes of input/output tensor named.
*/
const zdl::DlSystem::TensorShape getBufferAttributesDims(const char *name) const noexcept;
private:
PSNPE(const PSNPE&) = delete;
PSNPE& operator=(const PSNPE&) = delete;
zdl::PSNPE::InputOutputTransmissionMode m_TransmissionMode;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // namespace PSNPE
} // namespace zdl
#endif // PSNPE_HPP

View File

@ -0,0 +1,88 @@
//==============================================================================
//
// Copyright (c) 2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef PSNPE_RUNTIMECONFIGLIST_HPP
#define PSNPE_RUNTIMECONFIGLIST_HPP
#include <iostream>
#include "DlSystem/DlEnums.hpp"
#include "DlContainer/IDlContainer.hpp"
#include "DlSystem/ZdlExportDefine.hpp"
#include "DlSystem/RuntimeList.hpp"
namespace zdl {
namespace PSNPE
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* The structure for configuring a BulkSNPE runtime
*
*/
struct ZDL_EXPORT RuntimeConfig final {
zdl::DlSystem::Runtime_t runtime;
zdl::DlSystem::RuntimeList runtimeList;
zdl::DlSystem::PerformanceProfile_t perfProfile;
bool enableCPUFallback;
RuntimeConfig(): runtime{zdl::DlSystem::Runtime_t::CPU_FLOAT32},
perfProfile{zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE},
enableCPUFallback{false}
{}
RuntimeConfig(const RuntimeConfig& other)
{
runtime = other.runtime;
runtimeList = other.runtimeList;
perfProfile = other.perfProfile;
enableCPUFallback = other.enableCPUFallback;
}
RuntimeConfig& operator=(const RuntimeConfig &other)
{
this->runtimeList = other.runtimeList;
this->runtime = other.runtime;
this->perfProfile = other.perfProfile;
this->enableCPUFallback = other.enableCPUFallback;
return *this;
}
~RuntimeConfig() {}
};
/**
* @brief .
*
* The class for creating a RuntimeConfig container.
*
*/
class ZDL_EXPORT RuntimeConfigList final
{
public:
RuntimeConfigList();
RuntimeConfigList(const size_t size);
void push_back(const RuntimeConfig &runtimeConfig);
RuntimeConfig& operator[](const size_t index);
RuntimeConfigList& operator =(const RuntimeConfigList &other);
size_t size() const noexcept;
size_t capacity() const noexcept;
void clear() noexcept;
~RuntimeConfigList() = default;
private:
void swap(const RuntimeConfigList &other);
std::vector<RuntimeConfig> m_runtimeConfigs;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // namespace PSNPE
} // namespace zdl
#endif //PSNPE_RUNTIMECONFIGLIST_HPP

View File

@ -83,6 +83,14 @@ public:
zdl::DlSystem::Optional<zdl::DlSystem::StringList>
getOutputTensorNames() const noexcept;
/**
* @brief Gets the name of output tensor from the input layer name
*
* @return Output tensor name.
*/
zdl::DlSystem::StringList
getOutputTensorNamesByLayerName(const char *name) const noexcept;
/**
* @brief Processes the input data and returns the output
*

View File

@ -1,6 +1,6 @@
//==============================================================================
//
// Copyright (c) 2017 Qualcomm Technologies, Inc.
// Copyright (c) 2017-2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
@ -15,6 +15,7 @@
#include "DlSystem/DlOptional.hpp"
#include "DlSystem/TensorShapeMap.hpp"
#include "DlSystem/PlatformConfig.hpp"
#include "DlSystem/RuntimeList.hpp"
namespace zdl {
namespace DlContainer
@ -55,6 +56,9 @@ public:
~SNPEBuilder();
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use
* setRuntimeProcessorOrder()
*
* @brief Sets the runtime processor.
*
* @param[in] targetRuntimeProcessor The target runtime.
@ -74,6 +78,17 @@ public:
SNPEBuilder& setPerformanceProfile(
zdl::DlSystem::PerformanceProfile_t performanceProfile);
/**
* @brief Sets the profiling level. Default profiling level for
* SNPEBuilder is off. Off and basic only applies to DSP runtime.
*
* @param[in] profilingLevel The target profiling level.
*
* @return The current instance of SNPEBuilder.
*/
SNPEBuilder& setProfilingLevel(
zdl::DlSystem::ProfilingLevel_t profilingLevel);
/**
* @brief Sets a preference for execution priority.
*
@ -104,6 +119,20 @@ public:
SNPEBuilder& setOutputLayers(
const zdl::DlSystem::StringList& outputLayerNames);
/**
* @brief Sets the output tensor names.
*
* @param[in] outputTensorNames List of tensor names to
* output. An empty list will
* result in producing output for the final
* output tensor of the model.
* The list will be copied.
*
* @return The current instance of SNPEBuilder.
*/
SNPEBuilder& setOutputTensors(
const zdl::DlSystem::StringList& outputTensorNames);
/**
* @brief Passes in a User-defined layer.
*
@ -144,6 +173,9 @@ public:
bool debugMode);
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use
* setRuntimeProcessorOrder()
*
* @brief Sets the mode of CPU fallback functionality.
*
* @param[in] mode This flag enables/disables the functionality
@ -185,6 +217,22 @@ public:
*/
SNPEBuilder& setInputDimensions(const zdl::DlSystem::TensorShapeMap& inputDimensionsMap);
/**
* @brief Sets the mode of init caching functionality.
*
* @param[in] mode This flag enables/disables the functionality of init caching.
* When init caching functionality is enabled, a set of init caches
* will be created during network building/initialization process
* and will be added to DLC container. If such DLC container is saved
* by the user, in subsequent network building/initialization processes
* these init caches will be loaded from the DLC so as to reduce initialization time.
* In disable mode, no init caches will be added to DLC container.
*
* @return The current instance of SNPEBuilder.
*/
SNPEBuilder& setInitCacheMode(
bool cacheMode);
/**
* @brief Returns an instance of SNPE based on the current parameters.
*
@ -202,6 +250,31 @@ public:
*/
SNPEBuilder& setPlatformConfig(const zdl::DlSystem::PlatformConfig& platformConfig);
/**
* @brief Sets network's runtime order of precedence. Example:
* CPU_FLOAT32, GPU_FLOAT16, AIP_FIXED8_TF
* Note:- setRuntimeProcessor() or setCPUFallbackMode() will be silently ignored when
* setRuntimeProcessorOrder() is invoked
*
* @param[in] runtimeList The list of runtime in order of precedence
*
* @return The current instance of SNPEBuilder.
*/
SNPEBuilder& setRuntimeProcessorOrder(const zdl::DlSystem::RuntimeList& runtimeList);
/**
* @brief Sets the unconsumed tensors as output
*
* @param[in] setOutput This enables unconsumed tensors (i.e)
* outputs which are not inputs to any
* layer (basically dead ends) to be marked
* for output
*
* @return The current instance of SNPEBuilder.
*/
SNPEBuilder& setUnconsumedTensorsAsOutputs(
bool setOutput);
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */

View File

@ -1,6 +1,6 @@
//==============================================================================
//
// Copyright (c) 2015-2016 Qualcomm Technologies, Inc.
// Copyright (c) 2015-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
@ -42,19 +42,35 @@ class ZDL_EXPORT SNPEFactory
public:
/**
* Indicates whether the supplied runtime is available on the
* Indicates whether the supplied runtime is available on the
* current platform.
*
*
* @param[in] runtime The target runtime to check.
*
* @return True if the supplied runtime is available; false,
*
* @param[in] option Extent to perform runtime available check.
*
* @return True if the supplied runtime is available; false,
* otherwise.
*/
static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime);
/**
* Indicates whether the supplied runtime is available on the
* current platform.
*
* @param[in] runtime The target runtime to check.
*
* @param[in] option Extent to perform runtime available check.
*
* @return True if the supplied runtime is available; false,
* otherwise.
*/
static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime,
zdl::DlSystem::RuntimeCheckOption_t option);
/**
* Gets a reference to the tensor factory.
*
*
* @return A reference to the tensor factory.
*/
static zdl::DlSystem::ITensorFactory& getTensorFactory();
@ -87,6 +103,17 @@ public:
*/
static bool setSNPEStorageLocation(const char* storagePath);
/**
* @brief Register a user-defined op package with SNPE.
*
* @param[in] regLibraryPath Path to the registration library
* that allows clients to register a set of operations that are
* part of the package, and share op info with SNPE
*
* @return True if successful, False otherwise.
*/
static bool addOpPackage( const std::string& regLibraryPath );
/**
* Indicates whether the OpenGL and OpenCL interoperability is supported
* on GPU platform.

View File

@ -0,0 +1,49 @@
//==============================================================================
//
// Copyright (c) 2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef PSNPE_USERBUFFERLIST_HPP
#define PSNPE_USERBUFFERLIST_HPP
#include <vector>
#include "DlSystem/UserBufferMap.hpp"
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl {
namespace PSNPE
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* The class for creating a UserBufferMap container.
*
*/
class ZDL_EXPORT UserBufferList final
{
public:
UserBufferList();
UserBufferList(const size_t size);
void push_back(const zdl::DlSystem::UserBufferMap &userBufferMap);
zdl::DlSystem::UserBufferMap& operator[](const size_t index);
UserBufferList& operator =(const UserBufferList &other);
size_t size() const noexcept;
size_t capacity() const noexcept;
void clear() noexcept;
~UserBufferList() = default;
private:
void swap(const UserBufferList &other);
std::vector<zdl::DlSystem::UserBufferMap> m_userBufferMaps;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // namespace PSNPE
} // namespace zdl
#endif //PSNPE_USERBUFFERLIST_HPP

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3.7
#!/usr/bin/env python3
import json
import os
import hashlib
@ -22,6 +22,7 @@ from common import android
from common.basedir import PERSIST
from common.api import Api
from common.params import Params
from common.realtime import sec_since_boot
from cereal.services import service_list
from selfdrive.swaglog import cloudlog
@ -272,8 +273,13 @@ def ws_proxy_send(ws, local_sock, signal_sock, end_event):
def ws_recv(ws, end_event):
while not end_event.is_set():
try:
data = ws.recv()
payload_queue.put_nowait(data)
opcode, data = ws.recv_data(control_frame=True)
if opcode in (ABNF.OPCODE_TEXT, ABNF.OPCODE_BINARY):
if opcode == ABNF.OPCODE_TEXT:
data = data.decode("utf-8")
payload_queue.put_nowait(data)
elif opcode == ABNF.OPCODE_PING:
Params().put("LastAthenaPingTime", str(int(sec_since_boot()*1e9)))
except WebSocketTimeoutException:
pass
except Exception:
@ -316,6 +322,7 @@ def main():
except Exception:
cloudlog.exception("athenad.main.exception")
conn_retries += 1
params.delete("LastAthenaPingTime")
time.sleep(backoff(conn_retries))

View File

@ -27,10 +27,10 @@ def main():
proc.join()
cloudlog.event("athenad exited", exitcode=proc.exitcode)
time.sleep(5)
except:
except Exception:
cloudlog.exception("manage_athenad.exception")
finally:
params.delete(ATHENA_MGR_PID_PARAM)
if __name__ == '__main__':
main()
main()

View File

@ -6,7 +6,6 @@
#include <signal.h>
#include <unistd.h>
#include <sched.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/time.h>
@ -29,6 +28,7 @@
#include "messaging.hpp"
#include <algorithm>
#include <bitset>
// double the FIFO size
#define RECV_SIZE (0x1000)
@ -56,7 +56,7 @@ struct __attribute__((packed)) timestamp_t {
};
libusb_context *ctx = NULL;
libusb_device_handle *dev_handle;
libusb_device_handle *dev_handle = NULL;
pthread_mutex_t usb_lock;
bool spoofing_started = false;
@ -95,7 +95,7 @@ void *safety_setter_thread(void *s) {
// switch to SILENT when CarVin param is read
while (1) {
if (do_exit) return NULL;
const int result = read_db_value(NULL, "CarVin", &value_vin, &value_vin_sz);
const int result = read_db_value("CarVin", &value_vin, &value_vin_sz);
if (value_vin_sz > 0) {
// sanity check VIN format
assert(value_vin_sz == 17);
@ -104,6 +104,7 @@ void *safety_setter_thread(void *s) {
usleep(100*1000);
}
LOGW("got CarVin %s", value_vin);
free(value_vin);
// VIN query done, stop listening to OBDII
pthread_mutex_lock(&usb_lock);
@ -117,7 +118,7 @@ void *safety_setter_thread(void *s) {
while (1) {
if (do_exit) return NULL;
const int result = read_db_value(NULL, "CarParams", &value, &value_sz);
const int result = read_db_value("CarParams", &value, &value_sz);
if (value_sz > 0) break;
usleep(100*1000);
}
@ -159,6 +160,11 @@ bool usb_connect() {
ignition_last = false;
if (dev_handle != NULL){
libusb_close(dev_handle);
dev_handle = NULL;
}
dev_handle = libusb_open_device_with_vid_pid(ctx, 0xbbaa, 0xddcc);
if (dev_handle == NULL) { goto fail; }
@ -177,13 +183,13 @@ bool usb_connect() {
err2 = libusb_control_transfer(dev_handle, 0xc0, 0xd4, 0, 0, fw_sig_buf + 64, 64, TIMEOUT);
if ((err == 64) && (err2 == 64)) {
printf("FW signature read\n");
write_db_value(NULL, "PandaFirmware", (const char *)fw_sig_buf, 128);
write_db_value("PandaFirmware", (const char *)fw_sig_buf, 128);
for (size_t i = 0; i < 8; i++){
fw_sig_hex_buf[2*i] = NIBBLE_TO_HEX(fw_sig_buf[i] >> 4);
fw_sig_hex_buf[2*i+1] = NIBBLE_TO_HEX(fw_sig_buf[i] & 0xF);
}
write_db_value(NULL, "PandaFirmwareHex", (const char *)fw_sig_hex_buf, 16);
write_db_value("PandaFirmwareHex", (const char *)fw_sig_hex_buf, 16);
}
else { goto fail; }
@ -193,7 +199,7 @@ bool usb_connect() {
if (err > 0) {
serial = (const char *)serial_buf;
serial_sz = strnlen(serial, err);
write_db_value(NULL, "PandaDongleId", serial, serial_sz);
write_db_value("PandaDongleId", serial, serial_sz);
printf("panda serial: %.*s\n", serial_sz, serial);
}
else { goto fail; }
@ -259,6 +265,7 @@ fail:
return false;
}
// must be called before threads or with mutex
void usb_retry_connect() {
LOG("attempting to connect");
while (!usb_connect()) { usleep(100*1000); }
@ -357,15 +364,32 @@ void can_health(PubSocket *publisher) {
uint8_t power_save_enabled;
} health;
// create message
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
auto healthData = event.initHealth();
bool received = false;
// recv from board
pthread_mutex_lock(&usb_lock);
do {
if (dev_handle != NULL) {
pthread_mutex_lock(&usb_lock);
cnt = libusb_control_transfer(dev_handle, 0xc0, 0xd2, 0, 0, (unsigned char*)&health, sizeof(health), TIMEOUT);
if (cnt != sizeof(health)) {
handle_usb_issue(cnt, __func__);
}
} while(cnt != sizeof(health));
pthread_mutex_unlock(&usb_lock);
pthread_mutex_unlock(&usb_lock);
received = (cnt == sizeof(health));
}
// No panda connected, send empty health packet
if (!received){
healthData.setHwType(cereal::HealthData::HwType::UNKNOWN);
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
publisher->send((char*)bytes.begin(), bytes.size());
return;
}
if (spoofing_started) {
health.ignition_line = 1;
@ -394,7 +418,7 @@ void can_health(PubSocket *publisher) {
if ((no_ignition_exp || (voltage_f < VBATT_PAUSE_CHARGING)) && cdp_mode && !ignition) {
char *disable_power_down = NULL;
size_t disable_power_down_sz = 0;
const int result = read_db_value(NULL, "DisablePowerDown", &disable_power_down, &disable_power_down_sz);
const int result = read_db_value("DisablePowerDown", &disable_power_down, &disable_power_down_sz);
if (disable_power_down_sz != 1 || disable_power_down[0] != '1') {
printf("TURN OFF CHARGING!\n");
pthread_mutex_lock(&usb_lock);
@ -432,9 +456,9 @@ void can_health(PubSocket *publisher) {
// clear VIN, CarParams, and set new safety on car start
if (ignition && !ignition_last) {
int result = delete_db_value(NULL, "CarVin");
int result = delete_db_value("CarVin");
assert((result == 0) || (result == ERR_NO_VALUE));
result = delete_db_value(NULL, "CarParams");
result = delete_db_value("CarParams");
assert((result == 0) || (result == ERR_NO_VALUE));
if (!safety_setter_thread_initialized) {
@ -475,12 +499,6 @@ void can_health(PubSocket *publisher) {
ignition_last = ignition;
// create message
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
auto healthData = event.initHealth();
// set fields
healthData.setUptime(health.uptime);
healthData.setVoltage(health.voltage);
@ -501,16 +519,26 @@ void can_health(PubSocket *publisher) {
healthData.setFaultStatus(cereal::HealthData::FaultStatus(health.fault_status));
healthData.setPowerSaveEnabled((bool)(health.power_save_enabled));
// Convert faults bitset to capnp list
std::bitset<sizeof(health.faults) * 8> fault_bits(health.faults);
auto faults = healthData.initFaults(fault_bits.count());
size_t i = 0;
for (size_t f = size_t(cereal::HealthData::FaultType::RELAY_MALFUNCTION);
f <= size_t(cereal::HealthData::FaultType::REGISTER_DIVERGENT); f++){
if (fault_bits.test(f)) {
faults.set(i, cereal::HealthData::FaultType(f));
i++;
}
}
// send to health
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
publisher->send((char*)bytes.begin(), bytes.size());
pthread_mutex_lock(&usb_lock);
// send heartbeat back to panda
pthread_mutex_lock(&usb_lock);
libusb_control_transfer(dev_handle, 0x40, 0xf3, 1, 0, NULL, 0, TIMEOUT);
pthread_mutex_unlock(&usb_lock);
}
@ -557,10 +585,19 @@ void can_send(SubSocket *subscriber) {
int sent;
pthread_mutex_lock(&usb_lock);
if (!fake_send) {
do {
err = libusb_bulk_transfer(dev_handle, 3, (uint8_t*)send, msg_count*0x10, &sent, TIMEOUT);
if (err != 0 || msg_count*0x10 != sent) { handle_usb_issue(err, __func__); }
// Try sending can messages. If the receive buffer on the panda is full it will NAK
// and libusb will try again. After 5ms, it will time out. We will drop the messages.
err = libusb_bulk_transfer(dev_handle, 3, (uint8_t*)send, msg_count*0x10, &sent, 5);
if (err == LIBUSB_ERROR_TIMEOUT) {
LOGW("Transmit buffer full");
break;
} else if (err != 0 || msg_count*0x10 != sent) {
LOGW("Error");
handle_usb_issue(err, __func__);
}
} while(err != 0);
}
@ -594,6 +631,9 @@ void *can_send_thread(void *crap) {
while (!do_exit) {
can_send(subscriber);
}
delete subscriber;
delete context;
return NULL;
}
@ -624,6 +664,9 @@ void *can_recv_thread(void *crap) {
next_frame_time += dt;
}
delete publisher;
delete c;
return NULL;
}
@ -639,6 +682,9 @@ void *can_health_thread(void *crap) {
can_health(publisher);
usleep(500*1000);
}
delete publisher;
delete c;
return NULL;
}
@ -795,7 +841,7 @@ void pigeon_init() {
usleep(100*1000);
// init from ubloxd
// To generate this data, run test/ubloxd.py with the print statements enabled in the write function in panda/python/serial.py
// To generate this data, run test/ubloxd.py with the print statements enabled in the write function in panda/python/serial.py
pigeon_send("\xB5\x62\x06\x00\x14\x00\x03\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x1E\x7F");
pigeon_send("\xB5\x62\x06\x3E\x00\x00\x44\xD2");
pigeon_send("\xB5\x62\x06\x00\x14\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x35");
@ -873,6 +919,8 @@ void *pigeon_thread(void *crap) {
cnt++;
}
delete publisher;
delete context;
return NULL;
}
@ -899,21 +947,30 @@ int main() {
loopback_can = true;
}
err = pthread_mutex_init(&usb_lock, NULL);
assert(err == 0);
// init libusb
err = libusb_init(&ctx);
assert(err == 0);
#if LIBUSB_API_VERSION >= 0x01000106
libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO);
#else
libusb_set_debug(ctx, 3);
#endif
// connect to the board
usb_retry_connect();
// create threads
pthread_t can_health_thread_handle;
err = pthread_create(&can_health_thread_handle, NULL,
can_health_thread, NULL);
assert(err == 0);
// connect to the board
pthread_mutex_lock(&usb_lock);
usb_retry_connect();
pthread_mutex_unlock(&usb_lock);
// create threads
pthread_t can_send_thread_handle;
err = pthread_create(&can_send_thread_handle, NULL,
can_send_thread, NULL);

View File

@ -21,7 +21,10 @@ if ARCH == "x86_64":
ARCH_DIR = 'x64'
else:
libraries = [':libcan_list_to_can_capnp.a', 'capnp', 'kj']
ARCH_DIR = 'aarch64'
if os.path.isdir("/system"):
ARCH_DIR = 'aarch64'
else:
ARCH_DIR = 'larch64'
setup(name='Boardd API Implementation',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
@ -32,7 +35,6 @@ setup(name='Boardd API Implementation',
library_dirs=[
'./',
PHONELIBS + '/capnp-cpp/' + ARCH_DIR + '/lib/',
PHONELIBS + '/capnp-c/' + ARCH_DIR + '/lib/'
],
sources=['boardd_api_impl.pyx'],
language="c++",

View File

@ -4,7 +4,8 @@ import sys
import time
import signal
import traceback
from panda import Panda
import usb1
from panda import Panda, PandaDFU
from multiprocessing import Pool
jungle = "JUNGLE" in os.environ
@ -21,27 +22,32 @@ def initializer():
def send_thread(sender_serial):
global jungle
try:
if jungle:
sender = PandaJungle(sender_serial)
else:
sender = Panda(sender_serial)
sender.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
sender.set_can_loopback(False)
while True:
try:
if jungle:
sender = PandaJungle(sender_serial)
else:
sender = Panda(sender_serial)
sender.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
can_sock = messaging.sub_sock('can')
sender.set_can_loopback(False)
can_sock = messaging.sub_sock('can')
while True:
# Send messages one bus 0 and 1
tsc = messaging.recv_one(can_sock)
snd = can_capnp_to_can_list(tsc.can)
snd = list(filter(lambda x: x[-1] <= 2, snd))
sender.can_send_many(snd)
while True:
tsc = messaging.recv_one(can_sock)
snd = can_capnp_to_can_list(tsc.can)
snd = list(filter(lambda x: x[-1] <= 2, snd))
# Drain panda message buffer
sender.can_recv()
except Exception:
traceback.print_exc()
try:
sender.can_send_many(snd)
except usb1.USBErrorTimeout:
pass
# Drain panda message buffer
sender.can_recv()
except Exception:
traceback.print_exc()
time.sleep(1)
if __name__ == "__main__":
if jungle:
@ -50,12 +56,22 @@ if __name__ == "__main__":
serials = Panda.list()
num_senders = len(serials)
if num_senders == 0:
print("No senders found. Exiting")
sys.exit(1)
else:
print("%d senders found. Starting broadcast" % num_senders)
if "FLASH" in os.environ:
for s in PandaDFU.list():
PandaDFU(s).recover()
time.sleep(1)
for s in serials:
Panda(s).recover()
Panda(s).flash()
pool = Pool(num_senders, initializer=initializer)
pool.map_async(send_thread, serials)

View File

@ -1,13 +1,24 @@
Import('env', 'arch', 'messaging', 'common', 'gpucommon', 'visionipc', 'cereal')
Import('env', 'arch', 'messaging', 'common', 'gpucommon', 'visionipc', 'cereal', 'webcam')
libs = ['m', 'pthread', common, 'jpeg', 'json', cereal, 'OpenCL', messaging, 'czmq', 'zmq', 'capnp', 'kj', 'capnp_c', visionipc, gpucommon]
libs = ['m', 'pthread', common, 'jpeg', cereal, 'OpenCL', messaging, 'czmq', 'zmq', 'capnp', 'kj', visionipc, gpucommon]
if arch == "aarch64":
libs += ['gsl', 'CB', 'adreno_utils', 'EGL', 'GLESv3', 'cutils', 'ui']
cameras = ['cameras/camera_qcom.c']
else:
cameras = ['cameras/camera_qcom.cc']
elif arch == "larch64":
libs += []
cameras = ['cameras/camera_frame_stream.cc']
cameras = ['cameras/camera_qcom2.c']
else:
if webcam:
libs += ['opencv_core', 'opencv_highgui', 'opencv_imgproc', 'opencv_videoio']
cameras = ['cameras/camera_webcam.cc']
env = env.Clone()
env.Append(CXXFLAGS = '-DWEBCAM')
env.Append(CFLAGS = '-DWEBCAM')
env.Append(CPPPATH = '/usr/local/include/opencv4')
else:
libs += []
cameras = ['cameras/camera_frame_stream.cc']
env.SharedLibrary('snapshot/visionipc',
["#selfdrive/common/visionipc.c", "#selfdrive/common/ipc.c"])
@ -15,5 +26,6 @@ env.SharedLibrary('snapshot/visionipc',
env.Program('camerad', [
'main.cc',
'transforms/rgb_to_yuv.c',
'imgproc/utils.cc',
cameras,
], LIBS=libs)

View File

@ -10,7 +10,10 @@
#define CAMERA_ID_OV8865 3
#define CAMERA_ID_IMX298_FLIPPED 4
#define CAMERA_ID_OV10640 5
#define CAMERA_ID_MAX 6
#define CAMERA_ID_LGC920 6
#define CAMERA_ID_LGC615 7
#define CAMERA_ID_AR0231 8
#define CAMERA_ID_MAX 9
#ifdef __cplusplus
extern "C" {

View File

@ -115,7 +115,7 @@ CameraInfo cameras_supported[CAMERA_ID_MAX] = {
.frame_width = 1632,
.frame_height = 1224,
.frame_stride = 2040, // seems right
.bayer = false,
.bayer = true,
.bayer_flip = 3,
.hdr = false
},

View File

@ -3,6 +3,7 @@
#include <stdbool.h>
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else

View File

@ -13,7 +13,7 @@
#include <pthread.h>
#include <czmq.h>
#include <capnp/serialize.h>
#include "msmb_isp.h"
#include "msmb_ispif.h"
#include "msmb_camera.h"
@ -24,7 +24,7 @@
#include "common/swaglog.h"
#include "common/params.h"
#include "cereal/gen/c/log.capnp.h"
#include "cereal/gen/cpp/log.capnp.h"
#include "sensor_i2c.h"
@ -99,7 +99,7 @@ CameraInfo cameras_supported[CAMERA_ID_MAX] = {
};
static void camera_release_buffer(void* cookie, int buf_idx) {
CameraState *s = cookie;
CameraState *s = (CameraState *)cookie;
// printf("camera_release_buffer %d\n", buf_idx);
s->ss[0].qbuf_info[buf_idx].dirty_buf = 1;
ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &s->ss[0].qbuf_info[buf_idx]);
@ -134,10 +134,10 @@ static void camera_init(CameraState *s, int camera_id, int camera_num,
}
int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type) {
int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, msm_camera_i2c_data_type data_type) {
struct msm_camera_i2c_reg_setting out_settings = {
.reg_setting = arr,
.size = size,
.size = (uint16_t)size,
.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
.data_type = data_type,
.delay = 0,
@ -151,7 +151,7 @@ int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size
static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, int frame_length) {
int err;
int analog_gain = min(gain, 448);
int analog_gain = std::min(gain, 448);
if (gain > 448) {
s->digital_gain = (512.0/(512-(gain))) / 8.0;
@ -177,12 +177,12 @@ static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, int
{0x3002,0x0,0}, // long autoexposure off
// FRM_LENGTH
{0x340, frame_length >> 8, 0}, {0x341, frame_length & 0xff, 0},
{0x340, (uint16_t)(frame_length >> 8), 0}, {0x341, (uint16_t)(frame_length & 0xff), 0},
// INTEG_TIME aka coarse_int_time_addr aka shutter speed
{0x202, integ_lines >> 8, 0}, {0x203, integ_lines & 0xff,0},
{0x202, (uint16_t)(integ_lines >> 8), 0}, {0x203, (uint16_t)(integ_lines & 0xff),0},
// global_gain_addr
// if you assume 1x gain is 32, 448 is 14x gain, aka 2^14=16384
{0x204, analog_gain >> 8, 0}, {0x205, analog_gain & 0xff,0},
{0x204, (uint16_t)(analog_gain >> 8), 0}, {0x205, (uint16_t)(analog_gain & 0xff),0},
// digital gain for colors: gain_greenR, gain_red, gain_blue, gain_greenB
/*{0x20e, digital_gain_gr >> 8, 0}, {0x20f,digital_gain_gr & 0xFF,0},
@ -222,13 +222,13 @@ static int ov8865_apply_exposure(CameraState *s, int gain, int integ_lines, int
//{0x104,0x1,0},
// FRM_LENGTH
{0x380e, frame_length >> 8, 0}, {0x380f, frame_length & 0xff, 0},
{0x380e, (uint16_t)(frame_length >> 8), 0}, {0x380f, (uint16_t)(frame_length & 0xff), 0},
// AEC EXPO
{0x3500, integ_lines >> 16, 0}, {0x3501, integ_lines >> 8, 0}, {0x3502, integ_lines & 0xff,0},
{0x3500, (uint16_t)(integ_lines >> 16), 0}, {0x3501, (uint16_t)(integ_lines >> 8), 0}, {0x3502, (uint16_t)(integ_lines & 0xff),0},
// AEC MANUAL
{0x3503, 0x4, 0},
// AEC GAIN
{0x3508, gain_bitmap, 0}, {0x3509, 0xf8, 0},
{0x3508, (uint16_t)(gain_bitmap), 0}, {0x3509, 0xf8, 0},
//{0x104,0x0,0},
};
@ -253,11 +253,11 @@ static int imx179_s5k3p8sp_apply_exposure(CameraState *s, int gain, int integ_li
{0x104,0x1,0},
// FRM_LENGTH
{0x340, frame_length >> 8, 0}, {0x341, frame_length & 0xff, 0},
{0x340, (uint16_t)(frame_length >> 8), 0}, {0x341, (uint16_t)(frame_length & 0xff), 0},
// coarse_int_time
{0x202, integ_lines >> 8, 0}, {0x203, integ_lines & 0xff,0},
{0x202, (uint16_t)(integ_lines >> 8), 0}, {0x203, (uint16_t)(integ_lines & 0xff),0},
// global_gain
{0x204, gain >> 8, 0}, {0x205, gain & 0xff,0},
{0x204, (uint16_t)(gain >> 8), 0}, {0x205, (uint16_t)(gain & 0xff),0},
{0x104,0x0,0},
};
@ -365,7 +365,7 @@ static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) {
integ_lines = frame_length * exposure_frac;
// See page 79 of the datasheet, this is the max allowed (-1 for phase adjust)
integ_lines = min(integ_lines, frame_length-11);
integ_lines = std::min(integ_lines, frame_length-11);
}
if (gain_frac >= 0) {
@ -437,7 +437,8 @@ void camera_autoexposure(CameraState *s, float grey_frac) {
static uint8_t* get_eeprom(int eeprom_fd, size_t *out_len) {
int err;
struct msm_eeprom_cfg_data cfg = {0};
struct msm_eeprom_cfg_data cfg;
memset(&cfg, 0, sizeof(struct msm_eeprom_cfg_data));
cfg.cfgtype = CFG_EEPROM_GET_CAL_DATA;
err = ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg);
assert(err >= 0);
@ -445,7 +446,7 @@ static uint8_t* get_eeprom(int eeprom_fd, size_t *out_len) {
uint32_t num_bytes = cfg.cfg.get_data.num_bytes;
assert(num_bytes > 100);
uint8_t* buffer = malloc(num_bytes);
uint8_t* buffer = (uint8_t*)malloc(num_bytes);
assert(buffer);
memset(buffer, 0, num_bytes);
@ -537,7 +538,8 @@ static void sensors_init(DualCameraState *s) {
}
assert(sensorinit_fd >= 0);
struct sensor_init_cfg_data sensor_init_cfg = {0};
struct sensor_init_cfg_data sensor_init_cfg;
memset(&sensor_init_cfg, 0, sizeof(struct sensor_init_cfg_data));
// init rear sensor
@ -549,10 +551,10 @@ static void sensors_init(DualCameraState *s) {
.actuator_name = "dw9800w",
.ois_name = "",
.flash_name = "pmic",
.camera_id = 0,
.camera_id = CAMERA_0,
.slave_addr = 32,
.i2c_freq_mode = 1,
.addr_type = 2,
.i2c_freq_mode = I2C_FAST_MODE,
.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
.sensor_id_info = {
.sensor_id_reg_addr = 22,
.sensor_id = 664,
@ -563,37 +565,37 @@ static void sensors_init(DualCameraState *s) {
.power_setting_array = {
.power_setting_a = {
{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 0,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 5,
.config_val = 2,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 3,
.config_val = 0,
.delay = 1,
},{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 24000000,
.delay = 1,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 2,
.delay = 10,
@ -602,32 +604,32 @@ static void sensors_init(DualCameraState *s) {
.size = 7,
.power_down_setting_a = {
{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 0,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 5,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 3,
.config_val = 0,
.delay = 1,
@ -638,10 +640,10 @@ static void sensors_init(DualCameraState *s) {
.is_init_params_valid = 0,
.sensor_init_params = {
.modes_supported = 1,
.position = 0,
.position = BACK_CAMERA_B,
.sensor_mount_angle = 90,
},
.output_format = 0,
.output_format = MSM_SENSOR_BAYER,
};
} else {
slave_info = (struct msm_camera_sensor_slave_info){
@ -649,10 +651,10 @@ static void sensors_init(DualCameraState *s) {
.eeprom_name = "sony_imx298",
.actuator_name = "rohm_bu63165gwl",
.ois_name = "rohm_bu63165gwl",
.camera_id = 0,
.camera_id = CAMERA_0,
.slave_addr = 52,
.i2c_freq_mode = 2,
.addr_type = 2,
.i2c_freq_mode = I2C_CUSTOM_MODE,
.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
.sensor_id_info = {
.sensor_id_reg_addr = 22,
.sensor_id = 664,
@ -661,47 +663,47 @@ static void sensors_init(DualCameraState *s) {
.power_setting_array = {
.power_setting_a = {
{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 2,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 2,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 2,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 2,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 6,
.config_val = 2,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 3,
.config_val = 0,
.delay = 5,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 4,
.config_val = 0,
.delay = 5,
},{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 24000000,
.delay = 2,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 2,
.delay = 2,
@ -710,42 +712,42 @@ static void sensors_init(DualCameraState *s) {
.size = 9,
.power_down_setting_a = {
{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 10,
},{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 4,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 3,
.config_val = 0,
.delay = 1,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 6,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 0,
@ -756,10 +758,10 @@ static void sensors_init(DualCameraState *s) {
.is_init_params_valid = 0,
.sensor_init_params = {
.modes_supported = 1,
.position = 0,
.position = BACK_CAMERA_B,
.sensor_mount_angle = 360,
},
.output_format = 0,
.output_format = MSM_SENSOR_BAYER,
};
}
slave_info.power_setting_array.power_setting =
@ -781,10 +783,10 @@ static void sensors_init(DualCameraState *s) {
.actuator_name = "",
.ois_name = "",
.flash_name = "",
.camera_id = 2,
.camera_id = CAMERA_2,
.slave_addr = 108,
.i2c_freq_mode = 1,
.addr_type = 2,
.i2c_freq_mode = I2C_FAST_MODE,
.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
.sensor_id_info = {
.sensor_id_reg_addr = 12299,
.sensor_id = 34917,
@ -795,32 +797,32 @@ static void sensors_init(DualCameraState *s) {
.power_setting_array = {
.power_setting_a = {
{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 5,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 0,
},{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 24000000,
.delay = 1,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 2,
.delay = 1,
@ -829,27 +831,27 @@ static void sensors_init(DualCameraState *s) {
.size = 6,
.power_down_setting_a = {
{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 5,
},{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 1,
@ -860,10 +862,10 @@ static void sensors_init(DualCameraState *s) {
.is_init_params_valid = 0,
.sensor_init_params = {
.modes_supported = 1,
.position = 1,
.position = FRONT_CAMERA_B,
.sensor_mount_angle = 270,
},
.output_format = 0,
.output_format = MSM_SENSOR_BAYER,
};
} else if (s->front.camera_id == CAMERA_ID_S5K3P8SP) {
// init front camera
@ -872,10 +874,10 @@ static void sensors_init(DualCameraState *s) {
.eeprom_name = "s5k3p8sp_m24c64s",
.actuator_name = "",
.ois_name = "",
.camera_id = 1,
.camera_id = CAMERA_1,
.slave_addr = 32,
.i2c_freq_mode = 1,
.addr_type = 2,
.i2c_freq_mode = I2C_FAST_MODE,
.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
.sensor_id_info = {
.sensor_id_reg_addr = 0,
.sensor_id = 12552,
@ -884,32 +886,32 @@ static void sensors_init(DualCameraState *s) {
.power_setting_array = {
.power_setting_a = {
{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 24000000,
.delay = 1,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 2,
.delay = 1,
@ -918,27 +920,27 @@ static void sensors_init(DualCameraState *s) {
.size = 6,
.power_down_setting_a = {
{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 1,
@ -949,10 +951,10 @@ static void sensors_init(DualCameraState *s) {
.is_init_params_valid = 0,
.sensor_init_params = {
.modes_supported = 1,
.position = 1,
.position = FRONT_CAMERA_B,
.sensor_mount_angle = 270,
},
.output_format = 0,
.output_format = MSM_SENSOR_BAYER,
};
} else {
// init front camera
@ -961,10 +963,10 @@ static void sensors_init(DualCameraState *s) {
.eeprom_name = "sony_imx179",
.actuator_name = "",
.ois_name = "",
.camera_id = 1,
.camera_id = CAMERA_1,
.slave_addr = 32,
.i2c_freq_mode = 1,
.addr_type = 2,
.i2c_freq_mode = I2C_FAST_MODE,
.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
.sensor_id_info = {
.sensor_id_reg_addr = 2,
.sensor_id = 377,
@ -973,27 +975,27 @@ static void sensors_init(DualCameraState *s) {
.power_setting_array = {
.power_setting_a = {
{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 0,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 2,
.delay = 0,
},{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 24000000,
.delay = 0,
@ -1002,27 +1004,27 @@ static void sensors_init(DualCameraState *s) {
.size = 5,
.power_down_setting_a = {
{
.seq_type = 0,
.seq_type = SENSOR_CLK,
.seq_val = 0,
.config_val = 0,
.delay = 0,
},{
.seq_type = 1,
.seq_type = SENSOR_GPIO,
.seq_val = 0,
.config_val = 0,
.delay = 1,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 0,
.config_val = 0,
.delay = 2,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 1,
.config_val = 0,
.delay = 0,
},{
.seq_type = 2,
.seq_type = SENSOR_VREG,
.seq_val = 2,
.config_val = 0,
.delay = 0,
@ -1033,10 +1035,10 @@ static void sensors_init(DualCameraState *s) {
.is_init_params_valid = 0,
.sensor_init_params = {
.modes_supported = 1,
.position = 1,
.position = FRONT_CAMERA_B,
.sensor_mount_angle = 270,
},
.output_format = 0,
.output_format = MSM_SENSOR_BAYER,
};
}
slave_info2.power_setting_array.power_setting =
@ -1053,22 +1055,34 @@ static void sensors_init(DualCameraState *s) {
static void camera_open(CameraState *s, bool rear) {
int err;
struct sensorb_cfg_data sensorb_cfg_data = {0};
struct csid_cfg_data csid_cfg_data = {0};
struct csiphy_cfg_data csiphy_cfg_data = {0};
struct msm_camera_csiphy_params csiphy_params = {0};
struct msm_camera_csid_params csid_params = {0};
struct msm_vfe_input_cfg input_cfg = {0};
struct msm_vfe_axi_stream_update_cmd update_cmd = {0};
struct v4l2_event_subscription sub = {0};
struct ispif_cfg_data ispif_cfg_data = {0};
struct msm_vfe_cfg_cmd_list cfg_cmd_list = {0};
struct sensorb_cfg_data sensorb_cfg_data;
memset(&sensorb_cfg_data, 0, sizeof(struct sensorb_cfg_data));
struct csid_cfg_data csid_cfg_data;
memset(&csid_cfg_data, 0, sizeof(struct csid_cfg_data));
struct csiphy_cfg_data csiphy_cfg_data;
memset(&csiphy_cfg_data, 0, sizeof(struct csiphy_cfg_data));
struct msm_camera_csiphy_params csiphy_params;
memset(&csiphy_params, 0, sizeof(struct msm_camera_csiphy_params));
struct msm_camera_csid_params csid_params;
memset(&csid_params, 0, sizeof(struct msm_camera_csid_params));
struct msm_vfe_input_cfg input_cfg;
memset(&input_cfg, 0, sizeof(struct msm_vfe_input_cfg));
struct msm_vfe_axi_stream_update_cmd update_cmd;
memset(&update_cmd, 0, sizeof(struct msm_vfe_axi_stream_update_cmd));
struct v4l2_event_subscription sub;
memset(&sub, 0, sizeof(struct v4l2_event_subscription));
struct ispif_cfg_data ispif_cfg_data;
memset(&ispif_cfg_data, 0, sizeof(struct ispif_cfg_data));
struct msm_vfe_cfg_cmd_list cfg_cmd_list;
memset(&cfg_cmd_list, 0, sizeof(struct msm_vfe_cfg_cmd_list));
struct msm_actuator_cfg_data actuator_cfg_data = {0};
struct msm_ois_cfg_data ois_cfg_data = {0};
struct msm_actuator_cfg_data actuator_cfg_data;
memset(&actuator_cfg_data, 0, sizeof(struct msm_actuator_cfg_data));
struct msm_ois_cfg_data ois_cfg_data;
memset(&ois_cfg_data, 0, sizeof(struct msm_ois_cfg_data));
// open devices
char *sensor_dev;
const char *sensor_dev;
if (rear) {
s->csid_fd = open("/dev/v4l-subdev3", O_RDWR | O_NONBLOCK);
assert(s->csid_fd >= 0);
@ -1333,7 +1347,7 @@ static void camera_open(CameraState *s, bool rear) {
}
},
.af_tuning_params = {
.initial_code = s->infinity_dac,
.initial_code = (int16_t)s->infinity_dac,
.pwd_step = 0,
.region_size = 1,
.total_steps = 512,
@ -1419,7 +1433,7 @@ static void camera_open(CameraState *s, bool rear) {
}
},
.af_tuning_params = {
.initial_code = s->infinity_dac,
.initial_code = (int16_t)s->infinity_dac,
.pwd_step = 0,
.region_size = 1,
.total_steps = 238,
@ -1512,7 +1526,7 @@ static void camera_open(CameraState *s, bool rear) {
StreamState *ss = &s->ss[i];
memset(&input_cfg, 0, sizeof(struct msm_vfe_input_cfg));
input_cfg.input_src = VFE_RAW_0+i;
input_cfg.input_src = (msm_vfe_input_src)(VFE_RAW_0+i);
input_cfg.input_pix_clk = s->pixel_clock;
input_cfg.d.rdi_cfg.cid = i;
input_cfg.d.rdi_cfg.frame_based = 1;
@ -1534,7 +1548,7 @@ static void camera_open(CameraState *s, bool rear) {
} else {
ss->stream_req.output_format = v4l2_fourcc('Q', 'M', 'E', 'T');
}
ss->stream_req.stream_src = RDI_INTF_0+i;
ss->stream_req.stream_src = (msm_vfe_axi_stream_src)(RDI_INTF_0+i);
#ifdef HIGH_FPS
if (rear) {
@ -1645,7 +1659,7 @@ static void rear_start(CameraState *s) {
actuator_cfg_data.cfgtype = CFG_SET_POSITION;
actuator_cfg_data.cfg.setpos = (struct msm_actuator_set_position_t){
.number_of_steps = 1,
.hw_params = (s->device != DEVICE_LP3) ? 0x0000e424 : 7,
.hw_params = (uint32_t)((s->device != DEVICE_LP3) ? 0x0000e424 : 7),
.pos = {s->infinity_dac, 0},
.delay = {0,}
};
@ -1690,9 +1704,9 @@ void actuator_move(CameraState *s, uint16_t target) {
struct msm_actuator_cfg_data actuator_cfg_data = {0};
actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS;
actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){
.dir = (step > 0) ? 0 : 1,
.sign_dir = (step > 0) ? 1 : -1,
.dest_step_pos = dest_step_pos,
.dir = (int8_t)((step > 0) ? 0 : 1),
.sign_dir = (int8_t)((step > 0) ? 1 : -1),
.dest_step_pos = (int16_t)dest_step_pos,
.num_steps = abs(step),
.curr_lens_pos = s->cur_lens_pos,
.ringing_params = &actuator_ringing_params,
@ -1719,13 +1733,15 @@ static void parse_autofocus(CameraState *s, uint8_t *d) {
for (int i = 0; i < NUM_FOCUS; i++) {
int doff = i*5+5;
s->confidence[i] = d[doff];
// this should just be a 10-bit signed int instead of 11
// TODO: write it in a nicer way
int16_t focus_t = (d[doff+1] << 3) | (d[doff+2] >> 5);
if (focus_t >= 1024) focus_t = -(2048-focus_t);
s->focus[i] = focus_t;
//printf("%x->%d ", d[doff], focus_t);
if (s->confidence[i] > 0x20) {
good_count++;
max_focus = max(max_focus, s->focus[i]);
max_focus = std::max(max_focus, s->focus[i]);
avg_focus += s->focus[i];
}
}
@ -1792,34 +1808,36 @@ static void front_start(CameraState *s) {
void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front) {
int err;
struct ispif_cfg_data ispif_cfg_data = {0};
struct ispif_cfg_data ispif_cfg_data;
memset(&ispif_cfg_data, 0, sizeof(struct ispif_cfg_data));
struct msm_ispif_param_data ispif_params = {0};
struct msm_ispif_param_data ispif_params;
memset(&ispif_params, 0, sizeof(struct msm_ispif_param_data));
ispif_params.num = 4;
// rear camera
ispif_params.entries[0].vfe_intf = 0;
ispif_params.entries[0].vfe_intf = VFE0;
ispif_params.entries[0].intftype = RDI0;
ispif_params.entries[0].num_cids = 1;
ispif_params.entries[0].cids[0] = 0;
ispif_params.entries[0].csid = 0;
ispif_params.entries[0].cids[0] = CID0;
ispif_params.entries[0].csid = CSID0;
// front camera
ispif_params.entries[1].vfe_intf = 1;
ispif_params.entries[1].vfe_intf = VFE1;
ispif_params.entries[1].intftype = RDI0;
ispif_params.entries[1].num_cids = 1;
ispif_params.entries[1].cids[0] = 0;
ispif_params.entries[1].csid = 2;
ispif_params.entries[1].cids[0] = CID0;
ispif_params.entries[1].csid = CSID2;
// rear camera (focus)
ispif_params.entries[2].vfe_intf = 0;
ispif_params.entries[2].vfe_intf = VFE0;
ispif_params.entries[2].intftype = RDI1;
ispif_params.entries[2].num_cids = 1;
ispif_params.entries[2].cids[0] = 1;
ispif_params.entries[2].csid = 0;
ispif_params.entries[2].num_cids = CID1;
ispif_params.entries[2].cids[0] = CID1;
ispif_params.entries[2].csid = CSID0;
// rear camera (stats, for AE)
ispif_params.entries[3].vfe_intf = 0;
ispif_params.entries[3].vfe_intf = VFE0;
ispif_params.entries[3].intftype = RDI2;
ispif_params.entries[3].num_cids = 1;
ispif_params.entries[3].cids[0] = 2;
ispif_params.entries[3].csid = 0;
ispif_params.entries[3].cids[0] = CID2;
ispif_params.entries[3].csid = CSID0;
assert(camera_bufs_rear);
assert(camera_bufs_front);
@ -1958,13 +1976,13 @@ static FrameMetadata get_frame_metadata(CameraState *s, uint32_t frame_id) {
// should never happen
return (FrameMetadata){
.frame_id = -1,
.frame_id = (uint32_t)-1,
};
}
static bool acceleration_from_sensor_sock(void* sock, float* vs) {
static bool acceleration_from_sensor_sock(void *sock, float *vs) {
int err;
bool ret = false;
zmq_msg_t msg;
err = zmq_msg_init(&msg);
assert(err == 0);
@ -1972,43 +1990,30 @@ static bool acceleration_from_sensor_sock(void* sock, float* vs) {
err = zmq_msg_recv(&msg, sock, 0);
assert(err >= 0);
struct capn ctx;
capn_init_mem(&ctx, zmq_msg_data(&msg), zmq_msg_size(&msg), 0);
void *data = zmq_msg_data(&msg);
size_t size = zmq_msg_size(&msg);
cereal_Event_ptr eventp;
eventp.p = capn_getp(capn_root(&ctx), 0, 1);
struct cereal_Event eventd;
cereal_read_Event(&eventd, eventp);
bool ret = false;
if (eventd.which == cereal_Event_sensorEvents) {
cereal_SensorEventData_list lst = eventd.sensorEvents;
int len = capn_len(lst);
for (int i=0; i<len; i++) {
struct cereal_SensorEventData sensord;
cereal_get_SensorEventData(&sensord, lst, i);
if (sensord.which == cereal_SensorEventData_acceleration) {
struct cereal_SensorEventData_SensorVec vecd;
cereal_read_SensorEventData_SensorVec(&vecd, sensord.acceleration);
int vlen = capn_len(vecd.v);
if (vlen < 3) {
continue; //wtf
auto amsg = kj::heapArray<capnp::word>(size / sizeof(capnp::word) + 1);
memcpy(amsg.begin(), data, size);
capnp::FlatArrayMessageReader cmsg(amsg);
auto event = cmsg.getRoot<cereal::Event>();
if (event.which() == cereal::Event::SENSOR_EVENTS) {
auto sensor_events = event.getSensorEvents();
for (auto sensor_event : sensor_events) {
if (sensor_event.which() == cereal::SensorEventData::ACCELERATION) {
auto v = sensor_event.getAcceleration().getV();
if (v.size() < 3) {
continue; //wtf
}
for (int j=0; j<3; j++) {
vs[j] = capn_to_f32(capn_get32(vecd.v, j));
for (int j = 0; j < 3; j++) {
vs[j] = v[j];
}
ret = true;
break;
}
}
}
capn_free(&ctx);
zmq_msg_close(&msg);
return ret;
}
@ -2163,7 +2168,7 @@ void cameras_run(DualCameraState *s) {
c->camera_bufs_metadata[buf_idx] = get_frame_metadata(c, isp_event_data->frame_id);
tbuffer_dispatch(&c->camera_tb, buf_idx);
} else {
uint8_t *d = c->ss[buffer].bufs[buf_idx].addr;
uint8_t *d = (uint8_t*)(c->ss[buffer].bufs[buf_idx].addr);
if (buffer == 1) {
parse_autofocus(c, d);
}
@ -2179,9 +2184,9 @@ void cameras_run(DualCameraState *s) {
c->frame_metadata[c->frame_metadata_idx] = (FrameMetadata){
.frame_id = isp_event_data->frame_id,
.timestamp_eof = timestamp,
.frame_length = c->cur_frame_length,
.integ_lines = c->cur_integ_lines,
.global_gain = c->cur_gain,
.frame_length = (unsigned int)c->cur_frame_length,
.integ_lines = (unsigned int)c->cur_integ_lines,
.global_gain = (unsigned int)c->cur_gain,
.lens_pos = c->cur_lens_pos,
.lens_sag = c->last_sag_acc_z,
.lens_err = c->focus_err,

View File

@ -81,17 +81,28 @@ __kernel void debayer10(__global uchar const * const in,
float4 p = convert_float4(pint);
#if NEW == 1
// now it's 0x2a
const float black_level = 42.0f;
// max on black level
p = max(0.0, p - black_level);
#else
// 64 is the black level of the sensor, remove
// (changed to 56 for HDR)
const float black_level = 56.0f;
// TODO: switch to max here?
p = (p - black_level);
#endif
#if NEW == 0
// correct vignetting (no pow function?)
// see https://www.eecis.udel.edu/~jye/lab_research/09/JiUp.pdf the A (4th order)
const float r = ((oy - RGB_HEIGHT/2)*(oy - RGB_HEIGHT/2) + (ox - RGB_WIDTH/2)*(ox - RGB_WIDTH/2));
const float fake_f = 700.0f; // should be 910, but this fits...
const float lil_a = (1.0f + r/(fake_f*fake_f));
p = p * lil_a * lil_a;
#endif
// rescale to 1.0
#if HDR
@ -114,8 +125,12 @@ __kernel void debayer10(__global uchar const * const in,
float3 c1 = (float3)(p.s0, (p.s1+p.s2)/2.0f, p.s3);
#endif
#if NEW
// TODO: new color correction
#else
// color correction
c1 = color_correct(c1);
#endif
#if HDR
// srgb gamma isn't right for YUV, so it's disabled for now

View File

@ -0,0 +1,110 @@
// const __constant float3 rgb_weights = (0.299, 0.587, 0.114); // opencv rgb2gray weights
// const __constant float3 bgr_weights = (0.114, 0.587, 0.299); // bgr2gray weights
// convert input rgb image to single channel then conv
__kernel void rgb2gray_conv2d(
const __global uchar * input,
__global short * output,
__constant short * filter,
__local uchar3 * cached
)
{
const int rowOffset = get_global_id(1) * IMAGE_W;
const int my = get_global_id(0) + rowOffset;
const int localRowLen = TWICE_HALF_FILTER_SIZE + get_local_size(0);
const int localRowOffset = ( get_local_id(1) + HALF_FILTER_SIZE ) * localRowLen;
const int myLocal = localRowOffset + get_local_id(0) + HALF_FILTER_SIZE;
// cache local pixels
cached[ myLocal ].x = input[ my * 3 ]; // r
cached[ myLocal ].y = input[ my * 3 + 1]; // g
cached[ myLocal ].z = input[ my * 3 + 2]; // b
// pad
if (
get_global_id(0) < HALF_FILTER_SIZE ||
get_global_id(0) > IMAGE_W - HALF_FILTER_SIZE - 1 ||
get_global_id(1) < HALF_FILTER_SIZE ||
get_global_id(1) > IMAGE_H - HALF_FILTER_SIZE - 1
)
{
barrier(CLK_LOCAL_MEM_FENCE);
return;
}
else
{
int localColOffset = -1;
int globalColOffset = -1;
// cache extra
if ( get_local_id(0) < HALF_FILTER_SIZE )
{
localColOffset = get_local_id(0);
globalColOffset = -HALF_FILTER_SIZE;
cached[ localRowOffset + get_local_id(0) ].x = input[ my * 3 - HALF_FILTER_SIZE * 3 ];
cached[ localRowOffset + get_local_id(0) ].y = input[ my * 3 - HALF_FILTER_SIZE * 3 + 1];
cached[ localRowOffset + get_local_id(0) ].z = input[ my * 3 - HALF_FILTER_SIZE * 3 + 2];
}
else if ( get_local_id(0) >= get_local_size(0) - HALF_FILTER_SIZE )
{
localColOffset = get_local_id(0) + TWICE_HALF_FILTER_SIZE;
globalColOffset = HALF_FILTER_SIZE;
cached[ myLocal + HALF_FILTER_SIZE ].x = input[ my * 3 + HALF_FILTER_SIZE * 3 ];
cached[ myLocal + HALF_FILTER_SIZE ].y = input[ my * 3 + HALF_FILTER_SIZE * 3 + 1];
cached[ myLocal + HALF_FILTER_SIZE ].z = input[ my * 3 + HALF_FILTER_SIZE * 3 + 2];
}
if ( get_local_id(1) < HALF_FILTER_SIZE )
{
cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].x = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 ];
cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].y = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + 1];
cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].z = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + 2];
if (localColOffset > 0)
{
cached[ get_local_id(1) * localRowLen + localColOffset ].x = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3];
cached[ get_local_id(1) * localRowLen + localColOffset ].y = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 1];
cached[ get_local_id(1) * localRowLen + localColOffset ].z = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 2];
}
}
else if ( get_local_id(1) >= get_local_size(1) -HALF_FILTER_SIZE )
{
int offset = ( get_local_id(1) + TWICE_HALF_FILTER_SIZE ) * localRowLen;
cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].x = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 ];
cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].y = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + 1];
cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].z = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + 2];
if (localColOffset > 0)
{
cached[ offset + localColOffset ].x = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3];
cached[ offset + localColOffset ].y = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 1];
cached[ offset + localColOffset ].z = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 2];
}
}
// sync
barrier(CLK_LOCAL_MEM_FENCE);
// perform convolution
int fIndex = 0;
short sum = 0;
for (int r = -HALF_FILTER_SIZE; r <= HALF_FILTER_SIZE; r++)
{
int curRow = r * localRowLen;
for (int c = -HALF_FILTER_SIZE; c <= HALF_FILTER_SIZE; c++, fIndex++)
{
if (!FLIP_RB){
// sum += dot(rgb_weights, cached[ myLocal + curRow + c ]) * filter[ fIndex ];
sum += (cached[ myLocal + curRow + c ].x / 3 + cached[ myLocal + curRow + c ].y / 2 + cached[ myLocal + curRow + c ].z / 9) * filter[ fIndex ];
} else {
// sum += dot(bgr_weights, cached[ myLocal + curRow + c ]) * filter[ fIndex ];
sum += (cached[ myLocal + curRow + c ].x / 9 + cached[ myLocal + curRow + c ].y / 2 + cached[ myLocal + curRow + c ].z / 3) * filter[ fIndex ];
}
}
}
output[my] = sum;
}
}

View File

@ -0,0 +1,34 @@
// calculate variance in each subregion
__kernel void var_pool(
const __global char * input,
__global ushort * output // should not be larger than 128*128 so uint16
)
{
const int xidx = get_global_id(0) + ROI_X_MIN;
const int yidx = get_global_id(1) + ROI_Y_MIN;
const int size = X_PITCH * Y_PITCH;
float fsum = 0;
char mean, max;
for (int i = 0; i < size; i++) {
int x_offset = i % X_PITCH;
int y_offset = i / X_PITCH;
fsum += input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X];
max = input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]>max ? input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]:max;
}
mean = convert_char_rte(fsum / size);
float fvar = 0;
for (int i = 0; i < size; i++) {
int x_offset = i % X_PITCH;
int y_offset = i / X_PITCH;
fvar += (input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X] - mean) * (input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X] - mean);
}
fvar = fvar / size;
output[(xidx-ROI_X_MIN)+(yidx-ROI_Y_MIN)*(ROI_X_MAX-ROI_X_MIN+1)] = convert_ushort_rte(5 * fvar + convert_float_rte(max));
}

View File

@ -0,0 +1,44 @@
#include "utils.h"
#include <stdio.h>
#include <algorithm>
// calculate score based on laplacians in one area
void get_lapmap_one(int16_t *lap, uint16_t *res, int x_pitch, int y_pitch) {
int size = x_pitch * y_pitch;
// avg and max of roi
float fsum = 0;
int16_t mean, max;
max = 0;
for (int i = 0; i < size; i++) {
int x_offset = i % x_pitch;
int y_offset = i / x_pitch;
fsum += lap[x_offset + y_offset*x_pitch];
max = std::max(lap[x_offset + y_offset*x_pitch], max);
}
mean = fsum / size;
// var of roi
float fvar = 0;
for (int i = 0; i < size; i++) {
int x_offset = i % x_pitch;
int y_offset = i / x_pitch;
fvar += (float)((lap[x_offset + y_offset*x_pitch] - mean) * (lap[x_offset + y_offset*x_pitch] - mean));
}
fvar = fvar / size;
*res = std::min(5 * fvar + max, (float)65535);
}
bool is_blur(uint16_t *lapmap) {
int n_roi = (ROI_X_MAX - ROI_X_MIN + 1) * (ROI_Y_MAX - ROI_Y_MIN + 1);
float bad_sum = 0;
for (int i = 0; i < n_roi; i++) {
if (*(lapmap + i) < LM_THRESH) {
bad_sum += 1/(float)n_roi;
}
}
return (bad_sum > LM_PREC_THRESH);
}

View File

@ -0,0 +1,30 @@
#ifndef IMGPROC_UTILS
#define IMGPROC_UTILS
#include <stdint.h>
#define NUM_SEGMENTS_X 8
#define NUM_SEGMENTS_Y 6
#define ROI_X_MIN 1
#define ROI_X_MAX 6
#define ROI_Y_MIN 2
#define ROI_Y_MAX 3
#define LM_THRESH 222
#define LM_PREC_THRESH 0.9
// only apply to QCOM
#define FULL_STRIDE_X 1280
#define FULL_STRIDE_Y 896
#define CONV_LOCAL_WORKSIZE 16
const int16_t lapl_conv_krnl[9] = {0, 1, 0,
1, -4, 1,
0, 1, 0};
void get_lapmap_one(int16_t *lap, uint16_t *res, int x_pitch, int y_pitch);
bool is_blur(uint16_t *lapmap);
#endif

View File

@ -0,0 +1,25 @@
#ifndef __UAPI_CAM_CPAS_H__
#define __UAPI_CAM_CPAS_H__
#include "cam_defs.h"
#define CAM_FAMILY_CAMERA_SS 1
#define CAM_FAMILY_CPAS_SS 2
/**
* struct cam_cpas_query_cap - CPAS query device capability payload
*
* @camera_family : Camera family type
* @reserved : Reserved field for alignment
* @camera_version : Camera platform version
* @cpas_version : Camera CPAS version within camera platform
*
*/
struct cam_cpas_query_cap {
uint32_t camera_family;
uint32_t reserved;
struct cam_hw_version camera_version;
struct cam_hw_version cpas_version;
};
#endif /* __UAPI_CAM_CPAS_H__ */

View File

@ -0,0 +1,477 @@
#ifndef __UAPI_CAM_DEFS_H__
#define __UAPI_CAM_DEFS_H__
#include <linux/videodev2.h>
#include <linux/types.h>
#include <linux/ioctl.h>
/* camera op codes */
#define CAM_COMMON_OPCODE_BASE 0x100
#define CAM_QUERY_CAP (CAM_COMMON_OPCODE_BASE + 0x1)
#define CAM_ACQUIRE_DEV (CAM_COMMON_OPCODE_BASE + 0x2)
#define CAM_START_DEV (CAM_COMMON_OPCODE_BASE + 0x3)
#define CAM_STOP_DEV (CAM_COMMON_OPCODE_BASE + 0x4)
#define CAM_CONFIG_DEV (CAM_COMMON_OPCODE_BASE + 0x5)
#define CAM_RELEASE_DEV (CAM_COMMON_OPCODE_BASE + 0x6)
#define CAM_SD_SHUTDOWN (CAM_COMMON_OPCODE_BASE + 0x7)
#define CAM_FLUSH_REQ (CAM_COMMON_OPCODE_BASE + 0x8)
#define CAM_COMMON_OPCODE_MAX (CAM_COMMON_OPCODE_BASE + 0x9)
#define CAM_EXT_OPCODE_BASE 0x200
#define CAM_CONFIG_DEV_EXTERNAL (CAM_EXT_OPCODE_BASE + 0x1)
/* camera handle type */
#define CAM_HANDLE_USER_POINTER 1
#define CAM_HANDLE_MEM_HANDLE 2
/* Generic Blob CmdBuffer header properties */
#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK 0xFFFFFF00
#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT 8
#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK 0xFF
#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT 0
/* Command Buffer Types */
#define CAM_CMD_BUF_DMI 0x1
#define CAM_CMD_BUF_DMI16 0x2
#define CAM_CMD_BUF_DMI32 0x3
#define CAM_CMD_BUF_DMI64 0x4
#define CAM_CMD_BUF_DIRECT 0x5
#define CAM_CMD_BUF_INDIRECT 0x6
#define CAM_CMD_BUF_I2C 0x7
#define CAM_CMD_BUF_FW 0x8
#define CAM_CMD_BUF_GENERIC 0x9
#define CAM_CMD_BUF_LEGACY 0xA
/**
* enum flush_type_t - Identifies the various flush types
*
* @CAM_FLUSH_TYPE_REQ: Flush specific request
* @CAM_FLUSH_TYPE_ALL: Flush all requests belonging to a context
* @CAM_FLUSH_TYPE_MAX: Max enum to validate flush type
*
*/
enum flush_type_t {
CAM_FLUSH_TYPE_REQ,
CAM_FLUSH_TYPE_ALL,
CAM_FLUSH_TYPE_MAX
};
/**
* struct cam_control - Structure used by ioctl control for camera
*
* @op_code: This is the op code for camera control
* @size: Control command size
* @handle_type: User pointer or shared memory handle
* @reserved: Reserved field for 64 bit alignment
* @handle: Control command payload
*/
struct cam_control {
uint32_t op_code;
uint32_t size;
uint32_t handle_type;
uint32_t reserved;
uint64_t handle;
};
/* camera IOCTL */
#define VIDIOC_CAM_CONTROL \
_IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control)
/**
* struct cam_hw_version - Structure for HW version of camera devices
*
* @major : Hardware version major
* @minor : Hardware version minor
* @incr : Hardware version increment
* @reserved : Reserved for 64 bit aligngment
*/
struct cam_hw_version {
uint32_t major;
uint32_t minor;
uint32_t incr;
uint32_t reserved;
};
/**
* struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices
*
* @non_secure: Device Non Secure IOMMU handle
* @secure: Device Secure IOMMU handle
*
*/
struct cam_iommu_handle {
int32_t non_secure;
int32_t secure;
};
/* camera secure mode */
#define CAM_SECURE_MODE_NON_SECURE 0
#define CAM_SECURE_MODE_SECURE 1
/* Camera Format Type */
#define CAM_FORMAT_BASE 0
#define CAM_FORMAT_MIPI_RAW_6 1
#define CAM_FORMAT_MIPI_RAW_8 2
#define CAM_FORMAT_MIPI_RAW_10 3
#define CAM_FORMAT_MIPI_RAW_12 4
#define CAM_FORMAT_MIPI_RAW_14 5
#define CAM_FORMAT_MIPI_RAW_16 6
#define CAM_FORMAT_MIPI_RAW_20 7
#define CAM_FORMAT_QTI_RAW_8 8
#define CAM_FORMAT_QTI_RAW_10 9
#define CAM_FORMAT_QTI_RAW_12 10
#define CAM_FORMAT_QTI_RAW_14 11
#define CAM_FORMAT_PLAIN8 12
#define CAM_FORMAT_PLAIN16_8 13
#define CAM_FORMAT_PLAIN16_10 14
#define CAM_FORMAT_PLAIN16_12 15
#define CAM_FORMAT_PLAIN16_14 16
#define CAM_FORMAT_PLAIN16_16 17
#define CAM_FORMAT_PLAIN32_20 18
#define CAM_FORMAT_PLAIN64 19
#define CAM_FORMAT_PLAIN128 20
#define CAM_FORMAT_ARGB 21
#define CAM_FORMAT_ARGB_10 22
#define CAM_FORMAT_ARGB_12 23
#define CAM_FORMAT_ARGB_14 24
#define CAM_FORMAT_DPCM_10_6_10 25
#define CAM_FORMAT_DPCM_10_8_10 26
#define CAM_FORMAT_DPCM_12_6_12 27
#define CAM_FORMAT_DPCM_12_8_12 28
#define CAM_FORMAT_DPCM_14_8_14 29
#define CAM_FORMAT_DPCM_14_10_14 30
#define CAM_FORMAT_NV21 31
#define CAM_FORMAT_NV12 32
#define CAM_FORMAT_TP10 33
#define CAM_FORMAT_YUV422 34
#define CAM_FORMAT_PD8 35
#define CAM_FORMAT_PD10 36
#define CAM_FORMAT_UBWC_NV12 37
#define CAM_FORMAT_UBWC_NV12_4R 38
#define CAM_FORMAT_UBWC_TP10 39
#define CAM_FORMAT_UBWC_P010 40
#define CAM_FORMAT_PLAIN8_SWAP 41
#define CAM_FORMAT_PLAIN8_10 42
#define CAM_FORMAT_PLAIN8_10_SWAP 43
#define CAM_FORMAT_YV12 44
#define CAM_FORMAT_Y_ONLY 45
#define CAM_FORMAT_MAX 46
/* camera rotaion */
#define CAM_ROTATE_CW_0_DEGREE 0
#define CAM_ROTATE_CW_90_DEGREE 1
#define CAM_RORATE_CW_180_DEGREE 2
#define CAM_ROTATE_CW_270_DEGREE 3
/* camera Color Space */
#define CAM_COLOR_SPACE_BASE 0
#define CAM_COLOR_SPACE_BT601_FULL 1
#define CAM_COLOR_SPACE_BT601625 2
#define CAM_COLOR_SPACE_BT601525 3
#define CAM_COLOR_SPACE_BT709 4
#define CAM_COLOR_SPACE_DEPTH 5
#define CAM_COLOR_SPACE_MAX 6
/* camera buffer direction */
#define CAM_BUF_INPUT 1
#define CAM_BUF_OUTPUT 2
#define CAM_BUF_IN_OUT 3
/* camera packet device Type */
#define CAM_PACKET_DEV_BASE 0
#define CAM_PACKET_DEV_IMG_SENSOR 1
#define CAM_PACKET_DEV_ACTUATOR 2
#define CAM_PACKET_DEV_COMPANION 3
#define CAM_PACKET_DEV_EEPOM 4
#define CAM_PACKET_DEV_CSIPHY 5
#define CAM_PACKET_DEV_OIS 6
#define CAM_PACKET_DEV_FLASH 7
#define CAM_PACKET_DEV_FD 8
#define CAM_PACKET_DEV_JPEG_ENC 9
#define CAM_PACKET_DEV_JPEG_DEC 10
#define CAM_PACKET_DEV_VFE 11
#define CAM_PACKET_DEV_CPP 12
#define CAM_PACKET_DEV_CSID 13
#define CAM_PACKET_DEV_ISPIF 14
#define CAM_PACKET_DEV_IFE 15
#define CAM_PACKET_DEV_ICP 16
#define CAM_PACKET_DEV_LRME 17
#define CAM_PACKET_DEV_MAX 18
/* constants */
#define CAM_PACKET_MAX_PLANES 3
/**
* struct cam_plane_cfg - Plane configuration info
*
* @width: Plane width in pixels
* @height: Plane height in lines
* @plane_stride: Plane stride in pixel
* @slice_height: Slice height in line (not used by ISP)
* @meta_stride: UBWC metadata stride
* @meta_size: UBWC metadata plane size
* @meta_offset: UBWC metadata offset
* @packer_config: UBWC packer config
* @mode_config: UBWC mode config
* @tile_config: UBWC tile config
* @h_init: UBWC horizontal initial coordinate in pixels
* @v_init: UBWC vertical initial coordinate in lines
*
*/
struct cam_plane_cfg {
uint32_t width;
uint32_t height;
uint32_t plane_stride;
uint32_t slice_height;
uint32_t meta_stride;
uint32_t meta_size;
uint32_t meta_offset;
uint32_t packer_config;
uint32_t mode_config;
uint32_t tile_config;
uint32_t h_init;
uint32_t v_init;
};
/**
* struct cam_cmd_buf_desc - Command buffer descriptor
*
* @mem_handle: Command buffer handle
* @offset: Command start offset
* @size: Size of the command buffer in bytes
* @length: Used memory in command buffer in bytes
* @type: Type of the command buffer
* @meta_data: Data type for private command buffer
* Between UMD and KMD
*
*/
struct cam_cmd_buf_desc {
int32_t mem_handle;
uint32_t offset;
uint32_t size;
uint32_t length;
uint32_t type;
uint32_t meta_data;
};
/**
* struct cam_buf_io_cfg - Buffer io configuration for buffers
*
* @mem_handle: Mem_handle array for the buffers.
* @offsets: Offsets for each planes in the buffer
* @planes: Per plane information
* @width: Main plane width in pixel
* @height: Main plane height in lines
* @format: Format of the buffer
* @color_space: Color space for the buffer
* @color_pattern: Color pattern in the buffer
* @bpp: Bit per pixel
* @rotation: Rotation information for the buffer
* @resource_type: Resource type associated with the buffer
* @fence: Fence handle
* @early_fence: Fence handle for early signal
* @aux_cmd_buf: An auxiliary command buffer that may be
* used for programming the IO
* @direction: Direction of the config
* @batch_size: Batch size in HFR mode
* @subsample_pattern: Subsample pattern. Used in HFR mode. It
* should be consistent with batchSize and
* CAMIF programming.
* @subsample_period: Subsample period. Used in HFR mode. It
* should be consistent with batchSize and
* CAMIF programming.
* @framedrop_pattern: Framedrop pattern
* @framedrop_period: Framedrop period
* @flag: Flags for extra information
* @direction: Buffer direction: input or output
* @padding: Padding for the structure
*
*/
struct cam_buf_io_cfg {
int32_t mem_handle[CAM_PACKET_MAX_PLANES];
uint32_t offsets[CAM_PACKET_MAX_PLANES];
struct cam_plane_cfg planes[CAM_PACKET_MAX_PLANES];
uint32_t format;
uint32_t color_space;
uint32_t color_pattern;
uint32_t bpp;
uint32_t rotation;
uint32_t resource_type;
int32_t fence;
int32_t early_fence;
struct cam_cmd_buf_desc aux_cmd_buf;
uint32_t direction;
uint32_t batch_size;
uint32_t subsample_pattern;
uint32_t subsample_period;
uint32_t framedrop_pattern;
uint32_t framedrop_period;
uint32_t flag;
uint32_t padding;
};
/**
* struct cam_packet_header - Camera packet header
*
* @op_code: Camera packet opcode
* @size: Size of the camera packet in bytes
* @request_id: Request id for this camera packet
* @flags: Flags for the camera packet
* @padding: Padding
*
*/
struct cam_packet_header {
uint32_t op_code;
uint32_t size;
uint64_t request_id;
uint32_t flags;
uint32_t padding;
};
/**
* struct cam_patch_desc - Patch structure
*
* @dst_buf_hdl: Memory handle for the dest buffer
* @dst_offset: Offset byte in the dest buffer
* @src_buf_hdl: Memory handle for the source buffer
* @src_offset: Offset byte in the source buffer
*
*/
struct cam_patch_desc {
int32_t dst_buf_hdl;
uint32_t dst_offset;
int32_t src_buf_hdl;
uint32_t src_offset;
};
/**
* struct cam_packet - Camera packet structure
*
* @header: Camera packet header
* @cmd_buf_offset: Command buffer start offset
* @num_cmd_buf: Number of the command buffer in the packet
* @io_config_offset: Buffer io configuration start offset
* @num_io_configs: Number of the buffer io configurations
* @patch_offset: Patch offset for the patch structure
* @num_patches: Number of the patch structure
* @kmd_cmd_buf_index: Command buffer index which contains extra
* space for the KMD buffer
* @kmd_cmd_buf_offset: Offset from the beginning of the command
* buffer for KMD usage.
* @payload: Camera packet payload
*
*/
struct cam_packet {
struct cam_packet_header header;
uint32_t cmd_buf_offset;
uint32_t num_cmd_buf;
uint32_t io_configs_offset;
uint32_t num_io_configs;
uint32_t patch_offset;
uint32_t num_patches;
uint32_t kmd_cmd_buf_index;
uint32_t kmd_cmd_buf_offset;
uint64_t payload[1];
};
/**
* struct cam_release_dev_cmd - Control payload for release devices
*
* @session_handle: Session handle for the release
* @dev_handle: Device handle for the release
*/
struct cam_release_dev_cmd {
int32_t session_handle;
int32_t dev_handle;
};
/**
* struct cam_start_stop_dev_cmd - Control payload for start/stop device
*
* @session_handle: Session handle for the start/stop command
* @dev_handle: Device handle for the start/stop command
*
*/
struct cam_start_stop_dev_cmd {
int32_t session_handle;
int32_t dev_handle;
};
/**
* struct cam_config_dev_cmd - Command payload for configure device
*
* @session_handle: Session handle for the command
* @dev_handle: Device handle for the command
* @offset: Offset byte in the packet handle.
* @packet_handle: Packet memory handle for the actual packet:
* struct cam_packet.
*
*/
struct cam_config_dev_cmd {
int32_t session_handle;
int32_t dev_handle;
uint64_t offset;
uint64_t packet_handle;
};
/**
* struct cam_query_cap_cmd - Payload for query device capability
*
* @size: Handle size
* @handle_type: User pointer or shared memory handle
* @caps_handle: Device specific query command payload
*
*/
struct cam_query_cap_cmd {
uint32_t size;
uint32_t handle_type;
uint64_t caps_handle;
};
/**
* struct cam_acquire_dev_cmd - Control payload for acquire devices
*
* @session_handle: Session handle for the acquire command
* @dev_handle: Device handle to be returned
* @handle_type: Resource handle type:
* 1 = user pointer, 2 = mem handle
* @num_resources: Number of the resources to be acquired
* @resources_hdl: Resource handle that refers to the actual
* resource array. Each item in this
* array is device specific resource structure
*
*/
struct cam_acquire_dev_cmd {
int32_t session_handle;
int32_t dev_handle;
uint32_t handle_type;
uint32_t num_resources;
uint64_t resource_hdl;
};
/**
* struct cam_flush_dev_cmd - Control payload for flush devices
*
* @version: Version
* @session_handle: Session handle for the acquire command
* @dev_handle: Device handle to be returned
* @flush_type: Flush type:
* 0 = flush specific request
* 1 = flush all
* @reserved: Reserved for 64 bit aligngment
* @req_id: Request id that needs to cancel
*
*/
struct cam_flush_dev_cmd {
uint64_t version;
int32_t session_handle;
int32_t dev_handle;
uint32_t flush_type;
uint32_t reserved;
int64_t req_id;
};
#endif /* __UAPI_CAM_DEFS_H__ */

View File

@ -0,0 +1,127 @@
#ifndef __UAPI_CAM_FD_H__
#define __UAPI_CAM_FD_H__
#include "cam_defs.h"
#define CAM_FD_MAX_FACES 35
#define CAM_FD_RAW_RESULT_ENTRIES 512
/* FD Op Codes */
#define CAM_PACKET_OPCODES_FD_FRAME_UPDATE 0x0
/* FD Command Buffer identifiers */
#define CAM_FD_CMD_BUFFER_ID_GENERIC 0x0
#define CAM_FD_CMD_BUFFER_ID_CDM 0x1
#define CAM_FD_CMD_BUFFER_ID_MAX 0x2
/* FD Blob types */
#define CAM_FD_BLOB_TYPE_SOC_CLOCK_BW_REQUEST 0x0
#define CAM_FD_BLOB_TYPE_RAW_RESULTS_REQUIRED 0x1
/* FD Resource IDs */
#define CAM_FD_INPUT_PORT_ID_IMAGE 0x0
#define CAM_FD_INPUT_PORT_ID_MAX 0x1
#define CAM_FD_OUTPUT_PORT_ID_RESULTS 0x0
#define CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS 0x1
#define CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER 0x2
#define CAM_FD_OUTPUT_PORT_ID_MAX 0x3
/**
* struct cam_fd_soc_clock_bw_request - SOC clock, bandwidth request info
*
* @clock_rate : Clock rate required while processing frame
* @bandwidth : Bandwidth required while processing frame
* @reserved : Reserved for future use
*/
struct cam_fd_soc_clock_bw_request {
uint64_t clock_rate;
uint64_t bandwidth;
uint64_t reserved[4];
};
/**
* struct cam_fd_face - Face properties
*
* @prop1 : Property 1 of face
* @prop2 : Property 2 of face
* @prop3 : Property 3 of face
* @prop4 : Property 4 of face
*
* Do not change this layout, this is inline with how HW writes
* these values directly when the buffer is programmed to HW
*/
struct cam_fd_face {
uint32_t prop1;
uint32_t prop2;
uint32_t prop3;
uint32_t prop4;
};
/**
* struct cam_fd_results - FD results layout
*
* @faces : Array of faces with face properties
* @face_count : Number of faces detected
* @reserved : Reserved for alignment
*
* Do not change this layout, this is inline with how HW writes
* these values directly when the buffer is programmed to HW
*/
struct cam_fd_results {
struct cam_fd_face faces[CAM_FD_MAX_FACES];
uint32_t face_count;
uint32_t reserved[3];
};
/**
* struct cam_fd_hw_caps - Face properties
*
* @core_version : FD core version
* @wrapper_version : FD wrapper version
* @raw_results_available : Whether raw results are available on this HW
* @supported_modes : Modes supported by this HW.
* @reserved : Reserved for future use
*/
struct cam_fd_hw_caps {
struct cam_hw_version core_version;
struct cam_hw_version wrapper_version;
uint32_t raw_results_available;
uint32_t supported_modes;
uint64_t reserved;
};
/**
* struct cam_fd_query_cap_cmd - FD Query capabilities information
*
* @device_iommu : FD IOMMU handles
* @cdm_iommu : CDM iommu handles
* @hw_caps : FD HW capabilities
* @reserved : Reserved for alignment
*/
struct cam_fd_query_cap_cmd {
struct cam_iommu_handle device_iommu;
struct cam_iommu_handle cdm_iommu;
struct cam_fd_hw_caps hw_caps;
uint64_t reserved;
};
/**
* struct cam_fd_acquire_dev_info - FD acquire device information
*
* @clk_bw_request : SOC clock, bandwidth request
* @priority : Priority for this acquire
* @mode : Mode in which to run FD HW.
* @get_raw_results : Whether this acquire needs face raw results
* while frame processing
* @reserved : Reserved field for 64 bit alignment
*/
struct cam_fd_acquire_dev_info {
struct cam_fd_soc_clock_bw_request clk_bw_request;
uint32_t priority;
uint32_t mode;
uint32_t get_raw_results;
uint32_t reserved[13];
};
#endif /* __UAPI_CAM_FD_H__ */

View File

@ -0,0 +1,179 @@
#ifndef __UAPI_CAM_ICP_H__
#define __UAPI_CAM_ICP_H__
#include "cam_defs.h"
/* icp, ipe, bps, cdm(ipe/bps) are used in querycap */
#define CAM_ICP_DEV_TYPE_A5 1
#define CAM_ICP_DEV_TYPE_IPE 2
#define CAM_ICP_DEV_TYPE_BPS 3
#define CAM_ICP_DEV_TYPE_IPE_CDM 4
#define CAM_ICP_DEV_TYPE_BPS_CDM 5
#define CAM_ICP_DEV_TYPE_MAX 5
/* definitions needed for icp aquire device */
#define CAM_ICP_RES_TYPE_BPS 1
#define CAM_ICP_RES_TYPE_IPE_RT 2
#define CAM_ICP_RES_TYPE_IPE 3
#define CAM_ICP_RES_TYPE_MAX 4
/* packet opcode types */
#define CAM_ICP_OPCODE_IPE_UPDATE 0
#define CAM_ICP_OPCODE_BPS_UPDATE 1
/* IPE input port resource type */
#define CAM_ICP_IPE_INPUT_IMAGE_FULL 0x0
#define CAM_ICP_IPE_INPUT_IMAGE_DS4 0x1
#define CAM_ICP_IPE_INPUT_IMAGE_DS16 0x2
#define CAM_ICP_IPE_INPUT_IMAGE_DS64 0x3
#define CAM_ICP_IPE_INPUT_IMAGE_FULL_REF 0x4
#define CAM_ICP_IPE_INPUT_IMAGE_DS4_REF 0x5
#define CAM_ICP_IPE_INPUT_IMAGE_DS16_REF 0x6
#define CAM_ICP_IPE_INPUT_IMAGE_DS64_REF 0x7
/* IPE output port resource type */
#define CAM_ICP_IPE_OUTPUT_IMAGE_DISPLAY 0x8
#define CAM_ICP_IPE_OUTPUT_IMAGE_VIDEO 0x9
#define CAM_ICP_IPE_OUTPUT_IMAGE_FULL_REF 0xA
#define CAM_ICP_IPE_OUTPUT_IMAGE_DS4_REF 0xB
#define CAM_ICP_IPE_OUTPUT_IMAGE_DS16_REF 0xC
#define CAM_ICP_IPE_OUTPUT_IMAGE_DS64_REF 0xD
#define CAM_ICP_IPE_IMAGE_MAX 0xE
/* BPS input port resource type */
#define CAM_ICP_BPS_INPUT_IMAGE 0x0
/* BPS output port resource type */
#define CAM_ICP_BPS_OUTPUT_IMAGE_FULL 0x1
#define CAM_ICP_BPS_OUTPUT_IMAGE_DS4 0x2
#define CAM_ICP_BPS_OUTPUT_IMAGE_DS16 0x3
#define CAM_ICP_BPS_OUTPUT_IMAGE_DS64 0x4
#define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BG 0x5
#define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BHIST 0x6
#define CAM_ICP_BPS_OUTPUT_IMAGE_REG1 0x7
#define CAM_ICP_BPS_OUTPUT_IMAGE_REG2 0x8
#define CAM_ICP_BPS_IO_IMAGES_MAX 0x9
/* Command meta types */
#define CAM_ICP_CMD_META_GENERIC_BLOB 0x1
/* Generic blob types */
#define CAM_ICP_CMD_GENERIC_BLOB_CLK 0x1
#define CAM_ICP_CMD_GENERIC_BLOB_CFG_IO 0x2
/**
* struct cam_icp_clk_bw_request
*
* @budget_ns: Time required to process frame
* @frame_cycles: Frame cycles needed to process the frame
* @rt_flag: Flag to indicate real time stream
* @uncompressed_bw: Bandwidth required to process frame
* @compressed_bw: Compressed bandwidth to process frame
*/
struct cam_icp_clk_bw_request {
uint64_t budget_ns;
uint32_t frame_cycles;
uint32_t rt_flag;
uint64_t uncompressed_bw;
uint64_t compressed_bw;
};
/**
* struct cam_icp_dev_ver - Device information for particular hw type
*
* This is used to get device version info of
* ICP, IPE, BPS and CDM related IPE and BPS from firmware
* and use this info in CAM_QUERY_CAP IOCTL
*
* @dev_type: hardware type for the cap info(icp, ipe, bps, cdm(ipe/bps))
* @reserved: reserved field
* @hw_ver: major, minor and incr values of a device version
*/
struct cam_icp_dev_ver {
uint32_t dev_type;
uint32_t reserved;
struct cam_hw_version hw_ver;
};
/**
* struct cam_icp_ver - ICP version info
*
* This strcuture is used for fw and api version
* this is used to get firmware version and api version from firmware
* and use this info in CAM_QUERY_CAP IOCTL
*
* @major: FW version major
* @minor: FW version minor
* @revision: FW version increment
*/
struct cam_icp_ver {
uint32_t major;
uint32_t minor;
uint32_t revision;
uint32_t reserved;
};
/**
* struct cam_icp_query_cap_cmd - ICP query device capability payload
*
* @dev_iommu_handle: icp iommu handles for secure/non secure modes
* @cdm_iommu_handle: iommu handles for secure/non secure modes
* @fw_version: firmware version info
* @api_version: api version info
* @num_ipe: number of ipes
* @num_bps: number of bps
* @dev_ver: returned device capability array
*/
struct cam_icp_query_cap_cmd {
struct cam_iommu_handle dev_iommu_handle;
struct cam_iommu_handle cdm_iommu_handle;
struct cam_icp_ver fw_version;
struct cam_icp_ver api_version;
uint32_t num_ipe;
uint32_t num_bps;
struct cam_icp_dev_ver dev_ver[CAM_ICP_DEV_TYPE_MAX];
};
/**
* struct cam_icp_res_info - ICP output resource info
*
* @format: format of the resource
* @width: width in pixels
* @height: height in lines
* @fps: fps
*/
struct cam_icp_res_info {
uint32_t format;
uint32_t width;
uint32_t height;
uint32_t fps;
};
/**
* struct cam_icp_acquire_dev_info - An ICP device info
*
* @scratch_mem_size: Output param - size of scratch memory
* @dev_type: device type (IPE_RT/IPE_NON_RT/BPS)
* @io_config_cmd_size: size of IO config command
* @io_config_cmd_handle: IO config command for each acquire
* @secure_mode: camera mode (secure/non secure)
* @chain_info: chaining info of FW device handles
* @in_res: resource info used for clock and bandwidth calculation
* @num_out_res: number of output resources
* @out_res: output resource
*/
struct cam_icp_acquire_dev_info {
uint32_t scratch_mem_size;
uint32_t dev_type;
uint32_t io_config_cmd_size;
int32_t io_config_cmd_handle;
uint32_t secure_mode;
int32_t chain_info;
struct cam_icp_res_info in_res;
uint32_t num_out_res;
struct cam_icp_res_info out_res[1];
} __attribute__((__packed__));
#endif /* __UAPI_CAM_ICP_H__ */

View File

@ -0,0 +1,379 @@
#ifndef __UAPI_CAM_ISP_H__
#define __UAPI_CAM_ISP_H__
#include "cam_defs.h"
#include "cam_isp_vfe.h"
#include "cam_isp_ife.h"
/* ISP driver name */
#define CAM_ISP_DEV_NAME "cam-isp"
/* HW type */
#define CAM_ISP_HW_BASE 0
#define CAM_ISP_HW_CSID 1
#define CAM_ISP_HW_VFE 2
#define CAM_ISP_HW_IFE 3
#define CAM_ISP_HW_ISPIF 4
#define CAM_ISP_HW_MAX 5
/* Color Pattern */
#define CAM_ISP_PATTERN_BAYER_RGRGRG 0
#define CAM_ISP_PATTERN_BAYER_GRGRGR 1
#define CAM_ISP_PATTERN_BAYER_BGBGBG 2
#define CAM_ISP_PATTERN_BAYER_GBGBGB 3
#define CAM_ISP_PATTERN_YUV_YCBYCR 4
#define CAM_ISP_PATTERN_YUV_YCRYCB 5
#define CAM_ISP_PATTERN_YUV_CBYCRY 6
#define CAM_ISP_PATTERN_YUV_CRYCBY 7
#define CAM_ISP_PATTERN_MAX 8
/* Usage Type */
#define CAM_ISP_RES_USAGE_SINGLE 0
#define CAM_ISP_RES_USAGE_DUAL 1
#define CAM_ISP_RES_USAGE_MAX 2
/* Resource ID */
#define CAM_ISP_RES_ID_PORT 0
#define CAM_ISP_RES_ID_CLK 1
#define CAM_ISP_RES_ID_MAX 2
/* Resource Type - Type of resource for the resource id
* defined in cam_isp_vfe.h, cam_isp_ife.h
*/
/* Lane Type in input resource for Port */
#define CAM_ISP_LANE_TYPE_DPHY 0
#define CAM_ISP_LANE_TYPE_CPHY 1
#define CAM_ISP_LANE_TYPE_MAX 2
/* ISP Resurce Composite Group ID */
#define CAM_ISP_RES_COMP_GROUP_NONE 0
#define CAM_ISP_RES_COMP_GROUP_ID_0 1
#define CAM_ISP_RES_COMP_GROUP_ID_1 2
#define CAM_ISP_RES_COMP_GROUP_ID_2 3
#define CAM_ISP_RES_COMP_GROUP_ID_3 4
#define CAM_ISP_RES_COMP_GROUP_ID_4 5
#define CAM_ISP_RES_COMP_GROUP_ID_5 6
#define CAM_ISP_RES_COMP_GROUP_ID_MAX 6
/* ISP packet opcode for ISP */
#define CAM_ISP_PACKET_OP_BASE 0
#define CAM_ISP_PACKET_INIT_DEV 1
#define CAM_ISP_PACKET_UPDATE_DEV 2
#define CAM_ISP_PACKET_OP_MAX 3
/* ISP packet meta_data type for command buffer */
#define CAM_ISP_PACKET_META_BASE 0
#define CAM_ISP_PACKET_META_LEFT 1
#define CAM_ISP_PACKET_META_RIGHT 2
#define CAM_ISP_PACKET_META_COMMON 3
#define CAM_ISP_PACKET_META_DMI_LEFT 4
#define CAM_ISP_PACKET_META_DMI_RIGHT 5
#define CAM_ISP_PACKET_META_DMI_COMMON 6
#define CAM_ISP_PACKET_META_CLOCK 7
#define CAM_ISP_PACKET_META_CSID 8
#define CAM_ISP_PACKET_META_DUAL_CONFIG 9
#define CAM_ISP_PACKET_META_GENERIC_BLOB_LEFT 10
#define CAM_ISP_PACKET_META_GENERIC_BLOB_RIGHT 11
#define CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON 12
/* DSP mode */
#define CAM_ISP_DSP_MODE_NONE 0
#define CAM_ISP_DSP_MODE_ONE_WAY 1
#define CAM_ISP_DSP_MODE_ROUND 2
/* ISP Generic Cmd Buffer Blob types */
#define CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG 0
#define CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG 1
#define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG 2
/* Query devices */
/**
* struct cam_isp_dev_cap_info - A cap info for particular hw type
*
* @hw_type: Hardware type for the cap info
* @reserved: reserved field for alignment
* @hw_version: Hardware version
*
*/
struct cam_isp_dev_cap_info {
uint32_t hw_type;
uint32_t reserved;
struct cam_hw_version hw_version;
};
/**
* struct cam_isp_query_cap_cmd - ISP query device capability payload
*
* @device_iommu: returned iommu handles for device
* @cdm_iommu: returned iommu handles for cdm
* @num_dev: returned number of device capabilities
* @reserved: reserved field for alignment
* @dev_caps: returned device capability array
*
*/
struct cam_isp_query_cap_cmd {
struct cam_iommu_handle device_iommu;
struct cam_iommu_handle cdm_iommu;
int32_t num_dev;
uint32_t reserved;
struct cam_isp_dev_cap_info dev_caps[CAM_ISP_HW_MAX];
};
/* Acquire Device */
/**
* struct cam_isp_out_port_info - An output port resource info
*
* @res_type: output resource type defined in file
* cam_isp_vfe.h or cam_isp_ife.h
* @format: output format of the resource
* @wdith: output width in pixels
* @height: output height in lines
* @comp_grp_id: composite group id for the resource.
* @split_point: split point in pixels for the dual VFE.
* @secure_mode: flag to tell if output should be run in secure
* mode or not. See cam_defs.h for definition
* @reserved: reserved field for alignment
*
*/
struct cam_isp_out_port_info {
uint32_t res_type;
uint32_t format;
uint32_t width;
uint32_t height;
uint32_t comp_grp_id;
uint32_t split_point;
uint32_t secure_mode;
uint32_t reserved;
};
/**
* struct cam_isp_in_port_info - An input port resource info
*
* @res_type: input resource type define in file
* cam_isp_vfe.h or cam_isp_ife.h
* @lane_type: lane type: c-phy or d-phy.
* @lane_num: active lane number
* @lane_cfg: lane configurations: 4 bits per lane
* @vc: input virtual channel number
* @dt: input data type number
* @format: input format
* @test_pattern: test pattern for the testgen
* @usage_type: whether dual vfe is required
* @left_start: left input start offset in pixels
* @left_stop: left input stop offset in pixels
* @left_width: left input width in pixels
* @right_start: right input start offset in pixels.
* Only for Dual VFE
* @right_stop: right input stop offset in pixels.
* Only for Dual VFE
* @right_width: right input width in pixels.
* Only for dual VFE
* @line_start: top of the line number
* @line_stop: bottome of the line number
* @height: input height in lines
* @pixel_clk; sensor output clock
* @batch_size: batch size for HFR mode
* @dsp_mode: DSP stream mode (Defines as CAM_ISP_DSP_MODE_*)
* @hbi_cnt: HBI count for the camif input
* @reserved: Reserved field for alignment
* @num_out_res: number of the output resource associated
* @data: payload that contains the output resources
*
*/
struct cam_isp_in_port_info {
uint32_t res_type;
uint32_t lane_type;
uint32_t lane_num;
uint32_t lane_cfg;
uint32_t vc;
uint32_t dt;
uint32_t format;
uint32_t test_pattern;
uint32_t usage_type;
uint32_t left_start;
uint32_t left_stop;
uint32_t left_width;
uint32_t right_start;
uint32_t right_stop;
uint32_t right_width;
uint32_t line_start;
uint32_t line_stop;
uint32_t height;
uint32_t pixel_clk;
uint32_t batch_size;
uint32_t dsp_mode;
uint32_t hbi_cnt;
uint32_t custom_csid;
uint32_t reserved;
uint32_t num_out_res;
struct cam_isp_out_port_info data[1];
};
/**
* struct cam_isp_resource - A resource bundle
*
* @resoruce_id: resource id for the resource bundle
* @length: length of the while resource blob
* @handle_type: type of the resource handle
* @reserved: reserved field for alignment
* @res_hdl: resource handle that points to the
* resource array;
*
*/
struct cam_isp_resource {
uint32_t resource_id;
uint32_t length;
uint32_t handle_type;
uint32_t reserved;
uint64_t res_hdl;
};
/**
* struct cam_isp_port_hfr_config - HFR configuration for this port
*
* @resource_type: Resource type
* @subsample_pattern: Subsample pattern. Used in HFR mode. It
* should be consistent with batchSize and
* CAMIF programming.
* @subsample_period: Subsample period. Used in HFR mode. It
* should be consistent with batchSize and
* CAMIF programming.
* @framedrop_pattern: Framedrop pattern
* @framedrop_period: Framedrop period
* @reserved: Reserved for alignment
*/
struct cam_isp_port_hfr_config {
uint32_t resource_type;
uint32_t subsample_pattern;
uint32_t subsample_period;
uint32_t framedrop_pattern;
uint32_t framedrop_period;
uint32_t reserved;
} __attribute__((packed));
/**
* struct cam_isp_resource_hfr_config - Resource HFR configuration
*
* @num_ports: Number of ports
* @reserved: Reserved for alignment
* @port_hfr_config: HFR configuration for each IO port
*/
struct cam_isp_resource_hfr_config {
uint32_t num_ports;
uint32_t reserved;
struct cam_isp_port_hfr_config port_hfr_config[1];
} __attribute__((packed));
/**
* struct cam_isp_dual_split_params - dual isp spilt parameters
*
* @split_point: Split point information x, where (0 < x < width)
* left ISP's input ends at x + righ padding and
* Right ISP's input starts at x - left padding
* @right_padding: Padding added past the split point for left
* ISP's input
* @left_padding: Padding added before split point for right
* ISP's input
* @reserved: Reserved filed for alignment
*
*/
struct cam_isp_dual_split_params {
uint32_t split_point;
uint32_t right_padding;
uint32_t left_padding;
uint32_t reserved;
};
/**
* struct cam_isp_dual_stripe_config - stripe config per bus client
*
* @offset: Start horizontal offset relative to
* output buffer
* In UBWC mode, this value indicates the H_INIT
* value in pixel
* @width: Width of the stripe in bytes
* @tileconfig Ubwc meta tile config. Contain the partial
* tile info
* @port_id: port id of ISP output
*
*/
struct cam_isp_dual_stripe_config {
uint32_t offset;
uint32_t width;
uint32_t tileconfig;
uint32_t port_id;
};
/**
* struct cam_isp_dual_config - dual isp configuration
*
* @num_ports Number of isp output ports
* @reserved Reserved field for alignment
* @split_params: Inpput split parameters
* @stripes: Stripe information
*
*/
struct cam_isp_dual_config {
uint32_t num_ports;
uint32_t reserved;
struct cam_isp_dual_split_params split_params;
struct cam_isp_dual_stripe_config stripes[1];
} __attribute__((packed));
/**
* struct cam_isp_clock_config - Clock configuration
*
* @usage_type: Usage type (Single/Dual)
* @num_rdi: Number of RDI votes
* @left_pix_hz: Pixel Clock for Left ISP
* @right_pix_hz: Pixel Clock for Right ISP, valid only if Dual
* @rdi_hz: RDI Clock. ISP clock will be max of RDI and
* PIX clocks. For a particular context which ISP
* HW the RDI is allocated to is not known to UMD.
* Hence pass the clock and let KMD decide.
*/
struct cam_isp_clock_config {
uint32_t usage_type;
uint32_t num_rdi;
uint64_t left_pix_hz;
uint64_t right_pix_hz;
uint64_t rdi_hz[1];
} __attribute__((packed));
/**
* struct cam_isp_bw_vote - Bandwidth vote information
*
* @resource_id: Resource ID
* @reserved: Reserved field for alignment
* @cam_bw_bps: Bandwidth vote for CAMNOC
* @ext_bw_bps: Bandwidth vote for path-to-DDR after CAMNOC
*/
struct cam_isp_bw_vote {
uint32_t resource_id;
uint32_t reserved;
uint64_t cam_bw_bps;
uint64_t ext_bw_bps;
} __attribute__((packed));
/**
* struct cam_isp_bw_config - Bandwidth configuration
*
* @usage_type: Usage type (Single/Dual)
* @num_rdi: Number of RDI votes
* @left_pix_vote: Bandwidth vote for left ISP
* @right_pix_vote: Bandwidth vote for right ISP
* @rdi_vote: RDI bandwidth requirements
*/
struct cam_isp_bw_config {
uint32_t usage_type;
uint32_t num_rdi;
struct cam_isp_bw_vote left_pix_vote;
struct cam_isp_bw_vote right_pix_vote;
struct cam_isp_bw_vote rdi_vote[1];
} __attribute__((packed));
#endif /* __UAPI_CAM_ISP_H__ */

View File

@ -0,0 +1,39 @@
#ifndef __UAPI_CAM_ISP_IFE_H__
#define __UAPI_CAM_ISP_IFE_H__
/* IFE output port resource type (global unique)*/
#define CAM_ISP_IFE_OUT_RES_BASE 0x3000
#define CAM_ISP_IFE_OUT_RES_FULL (CAM_ISP_IFE_OUT_RES_BASE + 0)
#define CAM_ISP_IFE_OUT_RES_DS4 (CAM_ISP_IFE_OUT_RES_BASE + 1)
#define CAM_ISP_IFE_OUT_RES_DS16 (CAM_ISP_IFE_OUT_RES_BASE + 2)
#define CAM_ISP_IFE_OUT_RES_RAW_DUMP (CAM_ISP_IFE_OUT_RES_BASE + 3)
#define CAM_ISP_IFE_OUT_RES_FD (CAM_ISP_IFE_OUT_RES_BASE + 4)
#define CAM_ISP_IFE_OUT_RES_PDAF (CAM_ISP_IFE_OUT_RES_BASE + 5)
#define CAM_ISP_IFE_OUT_RES_RDI_0 (CAM_ISP_IFE_OUT_RES_BASE + 6)
#define CAM_ISP_IFE_OUT_RES_RDI_1 (CAM_ISP_IFE_OUT_RES_BASE + 7)
#define CAM_ISP_IFE_OUT_RES_RDI_2 (CAM_ISP_IFE_OUT_RES_BASE + 8)
#define CAM_ISP_IFE_OUT_RES_RDI_3 (CAM_ISP_IFE_OUT_RES_BASE + 9)
#define CAM_ISP_IFE_OUT_RES_STATS_HDR_BE (CAM_ISP_IFE_OUT_RES_BASE + 10)
#define CAM_ISP_IFE_OUT_RES_STATS_HDR_BHIST (CAM_ISP_IFE_OUT_RES_BASE + 11)
#define CAM_ISP_IFE_OUT_RES_STATS_TL_BG (CAM_ISP_IFE_OUT_RES_BASE + 12)
#define CAM_ISP_IFE_OUT_RES_STATS_BF (CAM_ISP_IFE_OUT_RES_BASE + 13)
#define CAM_ISP_IFE_OUT_RES_STATS_AWB_BG (CAM_ISP_IFE_OUT_RES_BASE + 14)
#define CAM_ISP_IFE_OUT_RES_STATS_BHIST (CAM_ISP_IFE_OUT_RES_BASE + 15)
#define CAM_ISP_IFE_OUT_RES_STATS_RS (CAM_ISP_IFE_OUT_RES_BASE + 16)
#define CAM_ISP_IFE_OUT_RES_STATS_CS (CAM_ISP_IFE_OUT_RES_BASE + 17)
#define CAM_ISP_IFE_OUT_RES_STATS_IHIST (CAM_ISP_IFE_OUT_RES_BASE + 18)
#define CAM_ISP_IFE_OUT_RES_MAX (CAM_ISP_IFE_OUT_RES_BASE + 19)
/* IFE input port resource type (global unique) */
#define CAM_ISP_IFE_IN_RES_BASE 0x4000
#define CAM_ISP_IFE_IN_RES_TPG (CAM_ISP_IFE_IN_RES_BASE + 0)
#define CAM_ISP_IFE_IN_RES_PHY_0 (CAM_ISP_IFE_IN_RES_BASE + 1)
#define CAM_ISP_IFE_IN_RES_PHY_1 (CAM_ISP_IFE_IN_RES_BASE + 2)
#define CAM_ISP_IFE_IN_RES_PHY_2 (CAM_ISP_IFE_IN_RES_BASE + 3)
#define CAM_ISP_IFE_IN_RES_PHY_3 (CAM_ISP_IFE_IN_RES_BASE + 4)
#define CAM_ISP_IFE_IN_RES_MAX (CAM_ISP_IFE_IN_RES_BASE + 5)
#endif /* __UAPI_CAM_ISP_IFE_H__ */

View File

@ -0,0 +1,44 @@
#ifndef __UAPI_CAM_ISP_VFE_H__
#define __UAPI_CAM_ISP_VFE_H__
/* VFE output port resource type (global unique) */
#define CAM_ISP_VFE_OUT_RES_BASE 0x1000
#define CAM_ISP_VFE_OUT_RES_ENC (CAM_ISP_VFE_OUT_RES_BASE + 0)
#define CAM_ISP_VFE_OUT_RES_VIEW (CAM_ISP_VFE_OUT_RES_BASE + 1)
#define CAM_ISP_VFE_OUT_RES_VID (CAM_ISP_VFE_OUT_RES_BASE + 2)
#define CAM_ISP_VFE_OUT_RES_RDI_0 (CAM_ISP_VFE_OUT_RES_BASE + 3)
#define CAM_ISP_VFE_OUT_RES_RDI_1 (CAM_ISP_VFE_OUT_RES_BASE + 4)
#define CAM_ISP_VFE_OUT_RES_RDI_2 (CAM_ISP_VFE_OUT_RES_BASE + 5)
#define CAM_ISP_VFE_OUT_RES_RDI_3 (CAM_ISP_VFE_OUT_RES_BASE + 6)
#define CAM_ISP_VFE_OUT_RES_STATS_AEC (CAM_ISP_VFE_OUT_RES_BASE + 7)
#define CAM_ISP_VFE_OUT_RES_STATS_AF (CAM_ISP_VFE_OUT_RES_BASE + 8)
#define CAM_ISP_VFE_OUT_RES_STATS_AWB (CAM_ISP_VFE_OUT_RES_BASE + 9)
#define CAM_ISP_VFE_OUT_RES_STATS_RS (CAM_ISP_VFE_OUT_RES_BASE + 10)
#define CAM_ISP_VFE_OUT_RES_STATS_CS (CAM_ISP_VFE_OUT_RES_BASE + 11)
#define CAM_ISP_VFE_OUT_RES_STATS_IHIST (CAM_ISP_VFE_OUT_RES_BASE + 12)
#define CAM_ISP_VFE_OUT_RES_STATS_SKIN (CAM_ISP_VFE_OUT_RES_BASE + 13)
#define CAM_ISP_VFE_OUT_RES_STATS_BG (CAM_ISP_VFE_OUT_RES_BASE + 14)
#define CAM_ISP_VFE_OUT_RES_STATS_BF (CAM_ISP_VFE_OUT_RES_BASE + 15)
#define CAM_ISP_VFE_OUT_RES_STATS_BE (CAM_ISP_VFE_OUT_RES_BASE + 16)
#define CAM_ISP_VFE_OUT_RES_STATS_BHIST (CAM_ISP_VFE_OUT_RES_BASE + 17)
#define CAM_ISP_VFE_OUT_RES_STATS_BF_SCALE (CAM_ISP_VFE_OUT_RES_BASE + 18)
#define CAM_ISP_VFE_OUT_RES_STATS_HDR_BE (CAM_ISP_VFE_OUT_RES_BASE + 19)
#define CAM_ISP_VFE_OUT_RES_STATS_HDR_BHIST (CAM_ISP_VFE_OUT_RES_BASE + 20)
#define CAM_ISP_VFE_OUT_RES_STATS_AEC_BG (CAM_ISP_VFE_OUT_RES_BASE + 21)
#define CAM_ISP_VFE_OUT_RES_CAMIF_RAW (CAM_ISP_VFE_OUT_RES_BASE + 22)
#define CAM_ISP_VFE_OUT_RES_IDEAL_RAW (CAM_ISP_VFE_OUT_RES_BASE + 23)
#define CAM_ISP_VFE_OUT_RES_MAX (CAM_ISP_VFE_OUT_RES_BASE + 24)
/* VFE input port_ resource type (global unique) */
#define CAM_ISP_VFE_IN_RES_BASE 0x2000
#define CAM_ISP_VFE_IN_RES_TPG (CAM_ISP_VFE_IN_RES_BASE + 0)
#define CAM_ISP_VFE_IN_RES_PHY_0 (CAM_ISP_VFE_IN_RES_BASE + 1)
#define CAM_ISP_VFE_IN_RES_PHY_1 (CAM_ISP_VFE_IN_RES_BASE + 2)
#define CAM_ISP_VFE_IN_RES_PHY_2 (CAM_ISP_VFE_IN_RES_BASE + 3)
#define CAM_ISP_VFE_IN_RES_PHY_3 (CAM_ISP_VFE_IN_RES_BASE + 4)
#define CAM_ISP_VFE_IN_RES_FE (CAM_ISP_VFE_IN_RES_BASE + 5)
#define CAM_ISP_VFE_IN_RES_MAX (CAM_ISP_VFE_IN_RES_BASE + 6)
#endif /* __UAPI_CAM_ISP_VFE_H__ */

View File

@ -0,0 +1,117 @@
#ifndef __UAPI_CAM_JPEG_H__
#define __UAPI_CAM_JPEG_H__
#include "cam_defs.h"
/* enc, dma, cdm(enc/dma) are used in querycap */
#define CAM_JPEG_DEV_TYPE_ENC 0
#define CAM_JPEG_DEV_TYPE_DMA 1
#define CAM_JPEG_DEV_TYPE_MAX 2
#define CAM_JPEG_NUM_DEV_PER_RES_MAX 1
/* definitions needed for jpeg aquire device */
#define CAM_JPEG_RES_TYPE_ENC 0
#define CAM_JPEG_RES_TYPE_DMA 1
#define CAM_JPEG_RES_TYPE_MAX 2
/* packet opcode types */
#define CAM_JPEG_OPCODE_ENC_UPDATE 0
#define CAM_JPEG_OPCODE_DMA_UPDATE 1
/* ENC input port resource type */
#define CAM_JPEG_ENC_INPUT_IMAGE 0x0
/* ENC output port resource type */
#define CAM_JPEG_ENC_OUTPUT_IMAGE 0x1
#define CAM_JPEG_ENC_IO_IMAGES_MAX 0x2
/* DMA input port resource type */
#define CAM_JPEG_DMA_INPUT_IMAGE 0x0
/* DMA output port resource type */
#define CAM_JPEG_DMA_OUTPUT_IMAGE 0x1
#define CAM_JPEG_DMA_IO_IMAGES_MAX 0x2
#define CAM_JPEG_IMAGE_MAX 0x2
/**
* struct cam_jpeg_dev_ver - Device information for particular hw type
*
* This is used to get device version info of JPEG ENC, JPEG DMA
* from hardware and use this info in CAM_QUERY_CAP IOCTL
*
* @size : Size of struct passed
* @dev_type: Hardware type for the cap info(jpeg enc, jpeg dma)
* @hw_ver: Major, minor and incr values of a device version
*/
struct cam_jpeg_dev_ver {
uint32_t size;
uint32_t dev_type;
struct cam_hw_version hw_ver;
};
/**
* struct cam_jpeg_query_cap_cmd - JPEG query device capability payload
*
* @dev_iommu_handle: Jpeg iommu handles for secure/non secure
* modes
* @cdm_iommu_handle: Iommu handles for secure/non secure modes
* @num_enc: Number of encoder
* @num_dma: Number of dma
* @dev_ver: Returned device capability array
*/
struct cam_jpeg_query_cap_cmd {
struct cam_iommu_handle dev_iommu_handle;
struct cam_iommu_handle cdm_iommu_handle;
uint32_t num_enc;
uint32_t num_dma;
struct cam_jpeg_dev_ver dev_ver[CAM_JPEG_DEV_TYPE_MAX];
};
/**
* struct cam_jpeg_res_info - JPEG output resource info
*
* @format: Format of the resource
* @width: Width in pixels
* @height: Height in lines
* @fps: Fps
*/
struct cam_jpeg_res_info {
uint32_t format;
uint32_t width;
uint32_t height;
uint32_t fps;
};
/**
* struct cam_jpeg_acquire_dev_info - An JPEG device info
*
* @dev_type: Device type (ENC/DMA)
* @reserved: Reserved Bytes
* @in_res: In resource info
* @in_res: Iut resource info
*/
struct cam_jpeg_acquire_dev_info {
uint32_t dev_type;
uint32_t reserved;
struct cam_jpeg_res_info in_res;
struct cam_jpeg_res_info out_res;
};
/**
* struct cam_jpeg_config_inout_param_info - JPEG Config time
* input output params
*
* @clk_index: Input Param- clock selection index.(-1 default)
* @output_size: Output Param - jpeg encode/dma output size in
* bytes
*/
struct cam_jpeg_config_inout_param_info {
int32_t clk_index;
int32_t output_size;
};
#endif /* __UAPI_CAM_JPEG_H__ */

View File

@ -0,0 +1,65 @@
#ifndef __UAPI_CAM_LRME_H__
#define __UAPI_CAM_LRME_H__
#include "cam_defs.h"
/* LRME Resource Types */
enum CAM_LRME_IO_TYPE {
CAM_LRME_IO_TYPE_TAR,
CAM_LRME_IO_TYPE_REF,
CAM_LRME_IO_TYPE_RES,
CAM_LRME_IO_TYPE_DS2,
};
#define CAM_LRME_INPUT_PORT_TYPE_TAR (1 << 0)
#define CAM_LRME_INPUT_PORT_TYPE_REF (1 << 1)
#define CAM_LRME_OUTPUT_PORT_TYPE_DS2 (1 << 0)
#define CAM_LRME_OUTPUT_PORT_TYPE_RES (1 << 1)
#define CAM_LRME_DEV_MAX 1
struct cam_lrme_hw_version {
uint32_t gen;
uint32_t rev;
uint32_t step;
};
struct cam_lrme_dev_cap {
struct cam_lrme_hw_version clc_hw_version;
struct cam_lrme_hw_version bus_rd_hw_version;
struct cam_lrme_hw_version bus_wr_hw_version;
struct cam_lrme_hw_version top_hw_version;
struct cam_lrme_hw_version top_titan_version;
};
/**
* struct cam_lrme_query_cap_cmd - LRME query device capability payload
*
* @dev_iommu_handle: LRME iommu handles for secure/non secure
* modes
* @cdm_iommu_handle: Iommu handles for secure/non secure modes
* @num_devices: number of hardware devices
* @dev_caps: Returned device capability array
*/
struct cam_lrme_query_cap_cmd {
struct cam_iommu_handle device_iommu;
struct cam_iommu_handle cdm_iommu;
uint32_t num_devices;
struct cam_lrme_dev_cap dev_caps[CAM_LRME_DEV_MAX];
};
struct cam_lrme_soc_info {
uint64_t clock_rate;
uint64_t bandwidth;
uint64_t reserved[4];
};
struct cam_lrme_acquire_args {
struct cam_lrme_soc_info lrme_soc_info;
};
#endif /* __UAPI_CAM_LRME_H__ */

View File

@ -0,0 +1,436 @@
#ifndef __UAPI_LINUX_CAM_REQ_MGR_H
#define __UAPI_LINUX_CAM_REQ_MGR_H
#include <linux/videodev2.h>
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/media.h>
#include <media/cam_defs.h>
#define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode"
#define CAM_DEVICE_TYPE_BASE (MEDIA_ENT_F_OLD_BASE)
#define CAM_VNODE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE)
#define CAM_SENSOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 1)
#define CAM_IFE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 2)
#define CAM_ICP_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 3)
#define CAM_LRME_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 4)
#define CAM_JPEG_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 5)
#define CAM_FD_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 6)
#define CAM_CPAS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 7)
#define CAM_CSIPHY_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 8)
#define CAM_ACTUATOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 9)
#define CAM_CCI_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 10)
#define CAM_FLASH_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 11)
#define CAM_EEPROM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 12)
#define CAM_OIS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 13)
/* cam_req_mgr hdl info */
#define CAM_REQ_MGR_HDL_IDX_POS 8
#define CAM_REQ_MGR_HDL_IDX_MASK ((1 << CAM_REQ_MGR_HDL_IDX_POS) - 1)
#define CAM_REQ_MGR_GET_HDL_IDX(hdl) (hdl & CAM_REQ_MGR_HDL_IDX_MASK)
/**
* Max handles supported by cam_req_mgr
* It includes both session and device handles
*/
#define CAM_REQ_MGR_MAX_HANDLES 64
#define MAX_LINKS_PER_SESSION 2
/* V4L event type which user space will subscribe to */
#define V4L_EVENT_CAM_REQ_MGR_EVENT (V4L2_EVENT_PRIVATE_START + 0)
/* Specific event ids to get notified in user space */
#define V4L_EVENT_CAM_REQ_MGR_SOF 0
#define V4L_EVENT_CAM_REQ_MGR_ERROR 1
#define V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS 2
/* SOF Event status */
#define CAM_REQ_MGR_SOF_EVENT_SUCCESS 0
#define CAM_REQ_MGR_SOF_EVENT_ERROR 1
/* Link control operations */
#define CAM_REQ_MGR_LINK_ACTIVATE 0
#define CAM_REQ_MGR_LINK_DEACTIVATE 1
/**
* Request Manager : flush_type
* @CAM_REQ_MGR_FLUSH_TYPE_ALL: Req mgr will remove all the pending
* requests from input/processing queue.
* @CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ: Req mgr will remove only particular
* request id from input/processing queue.
* @CAM_REQ_MGR_FLUSH_TYPE_MAX: Max number of the flush type
* @opcode: CAM_REQ_MGR_FLUSH_REQ
*/
#define CAM_REQ_MGR_FLUSH_TYPE_ALL 0
#define CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ 1
#define CAM_REQ_MGR_FLUSH_TYPE_MAX 2
/**
* Request Manager : Sync Mode type
* @CAM_REQ_MGR_SYNC_MODE_NO_SYNC: Req mgr will apply non-sync mode for this
* request.
* @CAM_REQ_MGR_SYNC_MODE_SYNC: Req mgr will apply sync mode for this request.
*/
#define CAM_REQ_MGR_SYNC_MODE_NO_SYNC 0
#define CAM_REQ_MGR_SYNC_MODE_SYNC 1
/**
* struct cam_req_mgr_event_data
* @session_hdl: session handle
* @link_hdl: link handle
* @frame_id: frame id
* @reserved: reserved for 64 bit aligngment
* @req_id: request id
* @tv_sec: timestamp in seconds
* @tv_usec: timestamp in micro seconds
*/
struct cam_req_mgr_event_data {
int32_t session_hdl;
int32_t link_hdl;
int32_t frame_id;
int32_t reserved;
int64_t req_id;
uint64_t tv_sec;
uint64_t tv_usec;
};
/**
* struct cam_req_mgr_session_info
* @session_hdl: In/Output param - session_handle
* @opcode1: CAM_REQ_MGR_CREATE_SESSION
* @opcode2: CAM_REQ_MGR_DESTROY_SESSION
*/
struct cam_req_mgr_session_info {
int32_t session_hdl;
int32_t reserved;
};
/**
* struct cam_req_mgr_link_info
* @session_hdl: Input param - Identifier for CSL session
* @num_devices: Input Param - Num of devices to be linked
* @dev_hdls: Input param - List of device handles to be linked
* @link_hdl: Output Param -Identifier for link
* @opcode: CAM_REQ_MGR_LINK
*/
struct cam_req_mgr_link_info {
int32_t session_hdl;
uint32_t num_devices;
int32_t dev_hdls[CAM_REQ_MGR_MAX_HANDLES];
int32_t link_hdl;
};
/**
* struct cam_req_mgr_unlink_info
* @session_hdl: input param - session handle
* @link_hdl: input param - link handle
* @opcode: CAM_REQ_MGR_UNLINK
*/
struct cam_req_mgr_unlink_info {
int32_t session_hdl;
int32_t link_hdl;
};
/**
* struct cam_req_mgr_flush_info
* @brief: User can tell drivers to flush a particular request id or
* flush all requests from its pending processing queue. Flush is a
* blocking call and driver shall ensure all requests are flushed
* before returning.
* @session_hdl: Input param - Identifier for CSL session
* @link_hdl: Input Param -Identifier for link
* @flush_type: User can cancel a particular req id or can flush
* all requests in queue
* @reserved: reserved for 64 bit aligngment
* @req_id: field is valid only if flush type is cancel request
* for flush all this field value is not considered.
* @opcode: CAM_REQ_MGR_FLUSH_REQ
*/
struct cam_req_mgr_flush_info {
int32_t session_hdl;
int32_t link_hdl;
uint32_t flush_type;
uint32_t reserved;
int64_t req_id;
};
/** struct cam_req_mgr_sched_info
* @session_hdl: Input param - Identifier for CSL session
* @link_hdl: Input Param -Identifier for link
* inluding itself.
* @bubble_enable: Input Param - Cam req mgr will do bubble recovery if this
* flag is set.
* @sync_mode: Type of Sync mode for this request
* @req_id: Input Param - Request Id from which all requests will be flushed
*/
struct cam_req_mgr_sched_request {
int32_t session_hdl;
int32_t link_hdl;
int32_t bubble_enable;
int32_t sync_mode;
int64_t req_id;
};
/**
* struct cam_req_mgr_sync_mode
* @session_hdl: Input param - Identifier for CSL session
* @sync_mode: Input Param - Type of sync mode
* @num_links: Input Param - Num of links in sync mode (Valid only
* when sync_mode is one of SYNC enabled modes)
* @link_hdls: Input Param - Array of link handles to be in sync mode
* (Valid only when sync_mode is one of SYNC
* enabled modes)
* @master_link_hdl: Input Param - To dictate which link's SOF drives system
* (Valid only when sync_mode is one of SYNC
* enabled modes)
*
* @opcode: CAM_REQ_MGR_SYNC_MODE
*/
struct cam_req_mgr_sync_mode {
int32_t session_hdl;
int32_t sync_mode;
int32_t num_links;
int32_t link_hdls[MAX_LINKS_PER_SESSION];
int32_t master_link_hdl;
int32_t reserved;
};
/**
* struct cam_req_mgr_link_control
* @ops: Link operations: activate/deactive
* @session_hdl: Input param - Identifier for CSL session
* @num_links: Input Param - Num of links
* @reserved: reserved field
* @link_hdls: Input Param - Links to be activated/deactivated
*
* @opcode: CAM_REQ_MGR_LINK_CONTROL
*/
struct cam_req_mgr_link_control {
int32_t ops;
int32_t session_hdl;
int32_t num_links;
int32_t reserved;
int32_t link_hdls[MAX_LINKS_PER_SESSION];
};
/**
* cam_req_mgr specific opcode ids
*/
#define CAM_REQ_MGR_CREATE_DEV_NODES (CAM_COMMON_OPCODE_MAX + 1)
#define CAM_REQ_MGR_CREATE_SESSION (CAM_COMMON_OPCODE_MAX + 2)
#define CAM_REQ_MGR_DESTROY_SESSION (CAM_COMMON_OPCODE_MAX + 3)
#define CAM_REQ_MGR_LINK (CAM_COMMON_OPCODE_MAX + 4)
#define CAM_REQ_MGR_UNLINK (CAM_COMMON_OPCODE_MAX + 5)
#define CAM_REQ_MGR_SCHED_REQ (CAM_COMMON_OPCODE_MAX + 6)
#define CAM_REQ_MGR_FLUSH_REQ (CAM_COMMON_OPCODE_MAX + 7)
#define CAM_REQ_MGR_SYNC_MODE (CAM_COMMON_OPCODE_MAX + 8)
#define CAM_REQ_MGR_ALLOC_BUF (CAM_COMMON_OPCODE_MAX + 9)
#define CAM_REQ_MGR_MAP_BUF (CAM_COMMON_OPCODE_MAX + 10)
#define CAM_REQ_MGR_RELEASE_BUF (CAM_COMMON_OPCODE_MAX + 11)
#define CAM_REQ_MGR_CACHE_OPS (CAM_COMMON_OPCODE_MAX + 12)
#define CAM_REQ_MGR_LINK_CONTROL (CAM_COMMON_OPCODE_MAX + 13)
/* end of cam_req_mgr opcodes */
#define CAM_MEM_FLAG_HW_READ_WRITE (1<<0)
#define CAM_MEM_FLAG_HW_READ_ONLY (1<<1)
#define CAM_MEM_FLAG_HW_WRITE_ONLY (1<<2)
#define CAM_MEM_FLAG_KMD_ACCESS (1<<3)
#define CAM_MEM_FLAG_UMD_ACCESS (1<<4)
#define CAM_MEM_FLAG_PROTECTED_MODE (1<<5)
#define CAM_MEM_FLAG_CMD_BUF_TYPE (1<<6)
#define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1<<7)
#define CAM_MEM_FLAG_STATS_BUF_TYPE (1<<8)
#define CAM_MEM_FLAG_PACKET_BUF_TYPE (1<<9)
#define CAM_MEM_FLAG_CACHE (1<<10)
#define CAM_MEM_FLAG_HW_SHARED_ACCESS (1<<11)
#define CAM_MEM_MMU_MAX_HANDLE 16
/* Maximum allowed buffers in existence */
#define CAM_MEM_BUFQ_MAX 1024
#define CAM_MEM_MGR_SECURE_BIT_POS 15
#define CAM_MEM_MGR_HDL_IDX_SIZE 15
#define CAM_MEM_MGR_HDL_FD_SIZE 16
#define CAM_MEM_MGR_HDL_IDX_END_POS 16
#define CAM_MEM_MGR_HDL_FD_END_POS 32
#define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1)
#define GET_MEM_HANDLE(idx, fd) \
((idx & CAM_MEM_MGR_HDL_IDX_MASK) | \
(fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \
#define GET_FD_FROM_HANDLE(hdl) \
(hdl >> (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE)) \
#define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
#define CAM_MEM_MGR_SET_SECURE_HDL(hdl, flag) \
((flag) ? (hdl |= (1 << CAM_MEM_MGR_SECURE_BIT_POS)) : \
((hdl) &= ~(1 << CAM_MEM_MGR_SECURE_BIT_POS)))
#define CAM_MEM_MGR_IS_SECURE_HDL(hdl) \
(((hdl) & \
(1<<CAM_MEM_MGR_SECURE_BIT_POS)) >> CAM_MEM_MGR_SECURE_BIT_POS)
/**
* memory allocation type
*/
#define CAM_MEM_DMA_NONE 0
#define CAM_MEM_DMA_BIDIRECTIONAL 1
#define CAM_MEM_DMA_TO_DEVICE 2
#define CAM_MEM_DMA_FROM_DEVICE 3
/**
* memory cache operation
*/
#define CAM_MEM_CLEAN_CACHE 1
#define CAM_MEM_INV_CACHE 2
#define CAM_MEM_CLEAN_INV_CACHE 3
/**
* struct cam_mem_alloc_out_params
* @buf_handle: buffer handle
* @fd: output buffer file descriptor
* @vaddr: virtual address pointer
*/
struct cam_mem_alloc_out_params {
uint32_t buf_handle;
int32_t fd;
uint64_t vaddr;
};
/**
* struct cam_mem_map_out_params
* @buf_handle: buffer handle
* @reserved: reserved for future
* @vaddr: virtual address pointer
*/
struct cam_mem_map_out_params {
uint32_t buf_handle;
uint32_t reserved;
uint64_t vaddr;
};
/**
* struct cam_mem_mgr_alloc_cmd
* @len: size of buffer to allocate
* @align: alignment of the buffer
* @mmu_hdls: array of mmu handles
* @num_hdl: number of handles
* @flags: flags of the buffer
* @out: out params
*/
/* CAM_REQ_MGR_ALLOC_BUF */
struct cam_mem_mgr_alloc_cmd {
uint64_t len;
uint64_t align;
int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
uint32_t num_hdl;
uint32_t flags;
struct cam_mem_alloc_out_params out;
};
/**
* struct cam_mem_mgr_map_cmd
* @mmu_hdls: array of mmu handles
* @num_hdl: number of handles
* @flags: flags of the buffer
* @fd: output buffer file descriptor
* @reserved: reserved field
* @out: out params
*/
/* CAM_REQ_MGR_MAP_BUF */
struct cam_mem_mgr_map_cmd {
int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
uint32_t num_hdl;
uint32_t flags;
int32_t fd;
uint32_t reserved;
struct cam_mem_map_out_params out;
};
/**
* struct cam_mem_mgr_map_cmd
* @buf_handle: buffer handle
* @reserved: reserved field
*/
/* CAM_REQ_MGR_RELEASE_BUF */
struct cam_mem_mgr_release_cmd {
int32_t buf_handle;
uint32_t reserved;
};
/**
* struct cam_mem_mgr_map_cmd
* @buf_handle: buffer handle
* @ops: cache operations
*/
/* CAM_REQ_MGR_CACHE_OPS */
struct cam_mem_cache_ops_cmd {
int32_t buf_handle;
uint32_t mem_cache_ops;
};
/**
* Request Manager : error message type
* @CAM_REQ_MGR_ERROR_TYPE_DEVICE: Device error message, fatal to session
* @CAM_REQ_MGR_ERROR_TYPE_REQUEST: Error on a single request, not fatal
* @CAM_REQ_MGR_ERROR_TYPE_BUFFER: Buffer was not filled, not fatal
*/
#define CAM_REQ_MGR_ERROR_TYPE_DEVICE 0
#define CAM_REQ_MGR_ERROR_TYPE_REQUEST 1
#define CAM_REQ_MGR_ERROR_TYPE_BUFFER 2
/**
* struct cam_req_mgr_error_msg
* @error_type: type of error
* @request_id: request id of frame
* @device_hdl: device handle
* @linke_hdl: link_hdl
* @resource_size: size of the resource
*/
struct cam_req_mgr_error_msg {
uint32_t error_type;
uint32_t request_id;
int32_t device_hdl;
int32_t link_hdl;
uint64_t resource_size;
};
/**
* struct cam_req_mgr_frame_msg
* @request_id: request id of the frame
* @frame_id: frame id of the frame
* @timestamp: timestamp of the frame
* @link_hdl: link handle associated with this message
* @sof_status: sof status success or fail
*/
struct cam_req_mgr_frame_msg {
uint64_t request_id;
uint64_t frame_id;
uint64_t timestamp;
int32_t link_hdl;
uint32_t sof_status;
};
/**
* struct cam_req_mgr_message
* @session_hdl: session to which the frame belongs to
* @reserved: reserved field
* @u: union which can either be error or frame message
*/
struct cam_req_mgr_message {
int32_t session_hdl;
int32_t reserved;
union {
struct cam_req_mgr_error_msg err_msg;
struct cam_req_mgr_frame_msg frame_msg;
} u;
};
#endif /* __UAPI_LINUX_CAM_REQ_MGR_H */

View File

@ -0,0 +1,477 @@
#ifndef __UAPI_CAM_SENSOR_H__
#define __UAPI_CAM_SENSOR_H__
#include <linux/types.h>
#include <linux/ioctl.h>
#include <media/cam_defs.h>
#define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1)
#define CAM_FLASH_MAX_LED_TRIGGERS 3
#define MAX_OIS_NAME_SIZE 32
#define CAM_CSIPHY_SECURE_MODE_ENABLED 1
/**
* struct cam_sensor_query_cap - capabilities info for sensor
*
* @slot_info : Indicates about the slotId or cell Index
* @secure_camera : Camera is in secure/Non-secure mode
* @pos_pitch : Sensor position pitch
* @pos_roll : Sensor position roll
* @pos_yaw : Sensor position yaw
* @actuator_slot_id : Actuator slot id which connected to sensor
* @eeprom_slot_id : EEPROM slot id which connected to sensor
* @ois_slot_id : OIS slot id which connected to sensor
* @flash_slot_id : Flash slot id which connected to sensor
* @csiphy_slot_id : CSIphy slot id which connected to sensor
*
*/
struct cam_sensor_query_cap {
uint32_t slot_info;
uint32_t secure_camera;
uint32_t pos_pitch;
uint32_t pos_roll;
uint32_t pos_yaw;
uint32_t actuator_slot_id;
uint32_t eeprom_slot_id;
uint32_t ois_slot_id;
uint32_t flash_slot_id;
uint32_t csiphy_slot_id;
} __attribute__((packed));
/**
* struct cam_csiphy_query_cap - capabilities info for csiphy
*
* @slot_info : Indicates about the slotId or cell Index
* @version : CSIphy version
* @clk lane : Of the 5 lanes, informs lane configured
* as clock lane
* @reserved
*/
struct cam_csiphy_query_cap {
uint32_t slot_info;
uint32_t version;
uint32_t clk_lane;
uint32_t reserved;
} __attribute__((packed));
/**
* struct cam_actuator_query_cap - capabilities info for actuator
*
* @slot_info : Indicates about the slotId or cell Index
* @reserved
*/
struct cam_actuator_query_cap {
uint32_t slot_info;
uint32_t reserved;
} __attribute__((packed));
/**
* struct cam_eeprom_query_cap_t - capabilities info for eeprom
*
* @slot_info : Indicates about the slotId or cell Index
* @eeprom_kernel_probe : Indicates about the kernel or userspace probe
*/
struct cam_eeprom_query_cap_t {
uint32_t slot_info;
uint16_t eeprom_kernel_probe;
uint16_t reserved;
} __attribute__((packed));
/**
* struct cam_ois_query_cap_t - capabilities info for ois
*
* @slot_info : Indicates about the slotId or cell Index
*/
struct cam_ois_query_cap_t {
uint32_t slot_info;
uint16_t reserved;
} __attribute__((packed));
/**
* struct cam_cmd_i2c_info - Contains slave I2C related info
*
* @slave_addr : Slave address
* @i2c_freq_mode : 4 bits are used for I2c freq mode
* @cmd_type : Explains type of command
*/
struct cam_cmd_i2c_info {
uint16_t slave_addr;
uint8_t i2c_freq_mode;
uint8_t cmd_type;
} __attribute__((packed));
/**
* struct cam_ois_opcode - Contains OIS opcode
*
* @prog : OIS FW prog register address
* @coeff : OIS FW coeff register address
* @pheripheral : OIS pheripheral
* @memory : OIS memory
*/
struct cam_ois_opcode {
uint32_t prog;
uint32_t coeff;
uint32_t pheripheral;
uint32_t memory;
} __attribute__((packed));
/**
* struct cam_cmd_ois_info - Contains OIS slave info
*
* @slave_addr : OIS i2c slave address
* @i2c_freq_mode : i2c frequency mode
* @cmd_type : Explains type of command
* @ois_fw_flag : indicates if fw is present or not
* @is_ois_calib : indicates the calibration data is available
* @ois_name : OIS name
* @opcode : opcode
*/
struct cam_cmd_ois_info {
uint16_t slave_addr;
uint8_t i2c_freq_mode;
uint8_t cmd_type;
uint8_t ois_fw_flag;
uint8_t is_ois_calib;
char ois_name[MAX_OIS_NAME_SIZE];
struct cam_ois_opcode opcode;
} __attribute__((packed));
/**
* struct cam_cmd_probe - Contains sensor slave info
*
* @data_type : Slave register data type
* @addr_type : Slave register address type
* @op_code : Don't Care
* @cmd_type : Explains type of command
* @reg_addr : Slave register address
* @expected_data : Data expected at slave register address
* @data_mask : Data mask if only few bits are valid
* @camera_id : Indicates the slot to which camera
* needs to be probed
* @reserved
*/
struct cam_cmd_probe {
uint8_t data_type;
uint8_t addr_type;
uint8_t op_code;
uint8_t cmd_type;
uint32_t reg_addr;
uint32_t expected_data;
uint32_t data_mask;
uint16_t camera_id;
uint16_t reserved;
} __attribute__((packed));
/**
* struct cam_power_settings - Contains sensor power setting info
*
* @power_seq_type : Type of power sequence
* @reserved
* @config_val_low : Lower 32 bit value configuration value
* @config_val_high : Higher 32 bit value configuration value
*
*/
struct cam_power_settings {
uint16_t power_seq_type;
uint16_t reserved;
uint32_t config_val_low;
uint32_t config_val_high;
} __attribute__((packed));
/**
* struct cam_cmd_power - Explains about the power settings
*
* @count : Number of power settings follows
* @reserved
* @cmd_type : Explains type of command
* @power_settings : Contains power setting info
*/
struct cam_cmd_power {
uint16_t count;
uint8_t reserved;
uint8_t cmd_type;
struct cam_power_settings power_settings[1];
} __attribute__((packed));
/**
* struct i2c_rdwr_header - header of READ/WRITE I2C command
*
* @ count : Number of registers / data / reg-data pairs
* @ op_code : Operation code
* @ cmd_type : Command buffer type
* @ data_type : I2C data type
* @ addr_type : I2C address type
* @ reserved
*/
struct i2c_rdwr_header {
uint16_t count;
uint8_t op_code;
uint8_t cmd_type;
uint8_t data_type;
uint8_t addr_type;
uint16_t reserved;
} __attribute__((packed));
/**
* struct i2c_random_wr_payload - payload for I2C random write
*
* @ reg_addr : Register address
* @ reg_data : Register data
*
*/
struct i2c_random_wr_payload {
uint32_t reg_addr;
uint32_t reg_data;
} __attribute__((packed));
/**
* struct cam_cmd_i2c_random_wr - I2C random write command
* @ header : header of READ/WRITE I2C command
* @ random_wr_payload : payload for I2C random write
*/
struct cam_cmd_i2c_random_wr {
struct i2c_rdwr_header header;
struct i2c_random_wr_payload random_wr_payload[1];
} __attribute__((packed));
/**
* struct cam_cmd_read - I2C read command
* @ reg_data : Register data
* @ reserved
*/
struct cam_cmd_read {
uint32_t reg_data;
uint32_t reserved;
} __attribute__((packed));
/**
* struct cam_cmd_i2c_continuous_wr - I2C continuous write command
* @ header : header of READ/WRITE I2C command
* @ reg_addr : Register address
* @ data_read : I2C read command
*/
struct cam_cmd_i2c_continuous_wr {
struct i2c_rdwr_header header;
uint32_t reg_addr;
struct cam_cmd_read data_read[1];
} __attribute__((packed));
/**
* struct cam_cmd_i2c_random_rd - I2C random read command
* @ header : header of READ/WRITE I2C command
* @ data_read : I2C read command
*/
struct cam_cmd_i2c_random_rd {
struct i2c_rdwr_header header;
struct cam_cmd_read data_read[1];
} __attribute__((packed));
/**
* struct cam_cmd_i2c_continuous_rd - I2C continuous continuous read command
* @ header : header of READ/WRITE I2C command
* @ reg_addr : Register address
*
*/
struct cam_cmd_i2c_continuous_rd {
struct i2c_rdwr_header header;
uint32_t reg_addr;
} __attribute__((packed));
/**
* struct cam_cmd_conditional_wait - Conditional wait command
* @data_type : Data type
* @addr_type : Address type
* @op_code : Opcode
* @cmd_type : Explains type of command
* @timeout : Timeout for retries
* @reserved
* @reg_addr : Register Address
* @reg_data : Register data
* @data_mask : Data mask if only few bits are valid
* @camera_id : Indicates the slot to which camera
* needs to be probed
*
*/
struct cam_cmd_conditional_wait {
uint8_t data_type;
uint8_t addr_type;
uint8_t op_code;
uint8_t cmd_type;
uint16_t timeout;
uint16_t reserved;
uint32_t reg_addr;
uint32_t reg_data;
uint32_t data_mask;
} __attribute__((packed));
/**
* struct cam_cmd_unconditional_wait - Un-conditional wait command
* @delay : Delay
* @op_code : Opcode
* @cmd_type : Explains type of command
*/
struct cam_cmd_unconditional_wait {
int16_t delay;
uint8_t op_code;
uint8_t cmd_type;
} __attribute__((packed));
/**
* cam_csiphy_info: Provides cmdbuffer structre
* @lane_mask : Lane mask details
* @lane_assign : Lane sensor will be using
* @csiphy_3phase : Total number of lanes
* @combo_mode : Info regarding combo_mode is enable / disable
* @lane_cnt : Total number of lanes
* @secure_mode : Secure mode flag to enable / disable
* @3phase : Details whether 3Phase / 2Phase operation
* @settle_time : Settling time in ms
* @data_rate : Data rate
*
*/
struct cam_csiphy_info {
uint16_t lane_mask;
uint16_t lane_assign;
uint8_t csiphy_3phase;
uint8_t combo_mode;
uint8_t lane_cnt;
uint8_t secure_mode;
uint64_t settle_time;
uint64_t data_rate;
} __attribute__((packed));
/**
* cam_csiphy_acquire_dev_info : Information needed for
* csiphy at the time of acquire
* @combo_mode : Indicates the device mode of operation
* @reserved
*
*/
struct cam_csiphy_acquire_dev_info {
uint32_t combo_mode;
uint32_t reserved;
} __attribute__((packed));
/**
* cam_sensor_acquire_dev : Updates sensor acuire cmd
* @device_handle : Updates device handle
* @session_handle : Session handle for acquiring device
* @handle_type : Resource handle type
* @reserved
* @info_handle : Handle to additional info
* needed for sensor sub modules
*
*/
struct cam_sensor_acquire_dev {
uint32_t session_handle;
uint32_t device_handle;
uint32_t handle_type;
uint32_t reserved;
uint64_t info_handle;
} __attribute__((packed));
/**
* cam_sensor_streamon_dev : StreamOn command for the sensor
* @session_handle : Session handle for acquiring device
* @device_handle : Updates device handle
* @handle_type : Resource handle type
* @reserved
* @info_handle : Information Needed at the time of streamOn
*
*/
struct cam_sensor_streamon_dev {
uint32_t session_handle;
uint32_t device_handle;
uint32_t handle_type;
uint32_t reserved;
uint64_t info_handle;
} __attribute__((packed));
/**
* struct cam_flash_init : Init command for the flash
* @flash_type : flash hw type
* @reserved
* @cmd_type : command buffer type
*/
struct cam_flash_init {
uint8_t flash_type;
uint16_t reserved;
uint8_t cmd_type;
} __attribute__((packed));
/**
* struct cam_flash_set_rer : RedEyeReduction command buffer
*
* @count : Number of flash leds
* @opcode : Command buffer opcode
* CAM_FLASH_FIRE_RER
* @cmd_type : command buffer operation type
* @num_iteration : Number of led turn on/off sequence
* @reserved
* @led_on_delay_ms : flash led turn on time in ms
* @led_off_delay_ms : flash led turn off time in ms
* @led_current_ma : flash led current in ma
*
*/
struct cam_flash_set_rer {
uint16_t count;
uint8_t opcode;
uint8_t cmd_type;
uint16_t num_iteration;
uint16_t reserved;
uint32_t led_on_delay_ms;
uint32_t led_off_delay_ms;
uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__((packed));
/**
* struct cam_flash_set_on_off : led turn on/off command buffer
*
* @count : Number of Flash leds
* @opcode : command buffer opcodes
* CAM_FLASH_FIRE_LOW
* CAM_FLASH_FIRE_HIGH
* CAM_FLASH_OFF
* @cmd_type : command buffer operation type
* @led_current_ma : flash led current in ma
*
*/
struct cam_flash_set_on_off {
uint16_t count;
uint8_t opcode;
uint8_t cmd_type;
uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__((packed));
/**
* struct cam_flash_query_curr : query current command buffer
*
* @reserved
* @opcode : command buffer opcode
* @cmd_type : command buffer operation type
* @query_current_ma : battery current in ma
*
*/
struct cam_flash_query_curr {
uint16_t reserved;
uint8_t opcode;
uint8_t cmd_type;
uint32_t query_current_ma;
} __attribute__ ((packed));
/**
* struct cam_flash_query_cap : capabilities info for flash
*
* @slot_info : Indicates about the slotId or cell Index
* @max_current_flash : max supported current for flash
* @max_duration_flash : max flash turn on duration
* @max_current_torch : max supported current for torch
*
*/
struct cam_flash_query_cap_info {
uint32_t slot_info;
uint32_t max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS];
uint32_t max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS];
uint32_t max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__ ((packed));
#endif

View File

@ -0,0 +1,391 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _CAM_SENSOR_CMN_HEADER_
#define _CAM_SENSOR_CMN_HEADER_
#include <stdbool.h>
#include <media/cam_sensor.h>
#include <media/cam_req_mgr.h>
#define MAX_REGULATOR 5
#define MAX_POWER_CONFIG 12
#define MAX_PER_FRAME_ARRAY 32
#define BATCH_SIZE_MAX 16
#define CAM_SENSOR_NAME "cam-sensor"
#define CAM_ACTUATOR_NAME "cam-actuator"
#define CAM_CSIPHY_NAME "cam-csiphy"
#define CAM_FLASH_NAME "cam-flash"
#define CAM_EEPROM_NAME "cam-eeprom"
#define CAM_OIS_NAME "cam-ois"
#define MAX_SYSTEM_PIPELINE_DELAY 2
#define CAM_PKT_NOP_OPCODE 127
enum camera_sensor_cmd_type {
CAMERA_SENSOR_CMD_TYPE_INVALID,
CAMERA_SENSOR_CMD_TYPE_PROBE,
CAMERA_SENSOR_CMD_TYPE_PWR_UP,
CAMERA_SENSOR_CMD_TYPE_PWR_DOWN,
CAMERA_SENSOR_CMD_TYPE_I2C_INFO,
CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR,
CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_RD,
CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR,
CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD,
CAMERA_SENSOR_CMD_TYPE_WAIT,
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO,
CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE,
CAMERA_SENSOR_FLASH_CMD_TYPE_RER,
CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR,
CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET,
CAMERA_SENSOR_CMD_TYPE_RD_DATA,
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE,
CAMERA_SENSOR_CMD_TYPE_MAX,
};
enum camera_sensor_i2c_op_code {
CAMERA_SENSOR_I2C_OP_INVALID,
CAMERA_SENSOR_I2C_OP_RNDM_WR,
CAMERA_SENSOR_I2C_OP_RNDM_WR_VERF,
CAMERA_SENSOR_I2C_OP_CONT_WR_BRST,
CAMERA_SENSOR_I2C_OP_CONT_WR_BRST_VERF,
CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN,
CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN_VERF,
CAMERA_SENSOR_I2C_OP_MAX,
};
enum camera_sensor_wait_op_code {
CAMERA_SENSOR_WAIT_OP_INVALID,
CAMERA_SENSOR_WAIT_OP_COND,
CAMERA_SENSOR_WAIT_OP_HW_UCND,
CAMERA_SENSOR_WAIT_OP_SW_UCND,
CAMERA_SENSOR_WAIT_OP_MAX,
};
enum camera_flash_opcode {
CAMERA_SENSOR_FLASH_OP_INVALID,
CAMERA_SENSOR_FLASH_OP_OFF,
CAMERA_SENSOR_FLASH_OP_FIRELOW,
CAMERA_SENSOR_FLASH_OP_FIREHIGH,
CAMERA_SENSOR_FLASH_OP_MAX,
};
enum camera_sensor_i2c_type {
CAMERA_SENSOR_I2C_TYPE_INVALID,
CAMERA_SENSOR_I2C_TYPE_BYTE,
CAMERA_SENSOR_I2C_TYPE_WORD,
CAMERA_SENSOR_I2C_TYPE_3B,
CAMERA_SENSOR_I2C_TYPE_DWORD,
CAMERA_SENSOR_I2C_TYPE_MAX,
};
enum i2c_freq_mode {
I2C_STANDARD_MODE,
I2C_FAST_MODE,
I2C_CUSTOM_MODE,
I2C_FAST_PLUS_MODE,
I2C_MAX_MODES,
};
enum position_roll {
ROLL_0 = 0,
ROLL_90 = 90,
ROLL_180 = 180,
ROLL_270 = 270,
ROLL_INVALID = 360,
};
enum position_yaw {
FRONT_CAMERA_YAW = 0,
REAR_CAMERA_YAW = 180,
INVALID_YAW = 360,
};
enum position_pitch {
LEVEL_PITCH = 0,
INVALID_PITCH = 360,
};
enum sensor_sub_module {
SUB_MODULE_SENSOR,
SUB_MODULE_ACTUATOR,
SUB_MODULE_EEPROM,
SUB_MODULE_LED_FLASH,
SUB_MODULE_CSID,
SUB_MODULE_CSIPHY,
SUB_MODULE_OIS,
SUB_MODULE_EXT,
SUB_MODULE_MAX,
};
enum msm_camera_power_seq_type {
SENSOR_MCLK,
SENSOR_VANA,
SENSOR_VDIG,
SENSOR_VIO,
SENSOR_VAF,
SENSOR_VAF_PWDM,
SENSOR_CUSTOM_REG1,
SENSOR_CUSTOM_REG2,
SENSOR_RESET,
SENSOR_STANDBY,
SENSOR_CUSTOM_GPIO1,
SENSOR_CUSTOM_GPIO2,
SENSOR_SEQ_TYPE_MAX,
};
enum cam_sensor_packet_opcodes {
CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMON,
CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE,
CAM_SENSOR_PACKET_OPCODE_SENSOR_INITIAL_CONFIG,
CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE,
CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG,
CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMOFF,
CAM_SENSOR_PACKET_OPCODE_SENSOR_NOP = 127
};
enum cam_actuator_packet_opcodes {
CAM_ACTUATOR_PACKET_OPCODE_INIT,
CAM_ACTUATOR_PACKET_AUTO_MOVE_LENS,
CAM_ACTUATOR_PACKET_MANUAL_MOVE_LENS
};
enum cam_eeprom_packet_opcodes {
CAM_EEPROM_PACKET_OPCODE_INIT
};
enum cam_ois_packet_opcodes {
CAM_OIS_PACKET_OPCODE_INIT,
CAM_OIS_PACKET_OPCODE_OIS_CONTROL
};
enum msm_bus_perf_setting {
S_INIT,
S_PREVIEW,
S_VIDEO,
S_CAPTURE,
S_ZSL,
S_STEREO_VIDEO,
S_STEREO_CAPTURE,
S_DEFAULT,
S_LIVESHOT,
S_DUAL,
S_EXIT
};
enum msm_camera_device_type_t {
MSM_CAMERA_I2C_DEVICE,
MSM_CAMERA_PLATFORM_DEVICE,
MSM_CAMERA_SPI_DEVICE,
};
enum cam_flash_device_type {
CAMERA_FLASH_DEVICE_TYPE_PMIC = 0,
CAMERA_FLASH_DEVICE_TYPE_I2C,
CAMERA_FLASH_DEVICE_TYPE_GPIO,
};
enum cci_i2c_master_t {
MASTER_0,
MASTER_1,
MASTER_MAX,
};
enum camera_vreg_type {
VREG_TYPE_DEFAULT,
VREG_TYPE_CUSTOM,
};
enum cam_sensor_i2c_cmd_type {
CAM_SENSOR_I2C_WRITE_RANDOM,
CAM_SENSOR_I2C_WRITE_BURST,
CAM_SENSOR_I2C_WRITE_SEQ,
CAM_SENSOR_I2C_READ,
CAM_SENSOR_I2C_POLL
};
struct common_header {
uint16_t first_word;
uint8_t third_byte;
uint8_t cmd_type;
};
struct camera_vreg_t {
const char *reg_name;
int min_voltage;
int max_voltage;
int op_mode;
uint32_t delay;
const char *custom_vreg_name;
enum camera_vreg_type type;
};
struct msm_camera_gpio_num_info {
uint16_t gpio_num[SENSOR_SEQ_TYPE_MAX];
uint8_t valid[SENSOR_SEQ_TYPE_MAX];
};
struct msm_cam_clk_info {
const char *clk_name;
long clk_rate;
uint32_t delay;
};
struct msm_pinctrl_info {
struct pinctrl *pinctrl;
struct pinctrl_state *gpio_state_active;
struct pinctrl_state *gpio_state_suspend;
bool use_pinctrl;
};
struct cam_sensor_i2c_reg_array {
uint32_t reg_addr;
uint32_t reg_data;
uint32_t delay;
uint32_t data_mask;
};
struct cam_sensor_i2c_reg_setting {
struct cam_sensor_i2c_reg_array *reg_setting;
unsigned short size;
enum camera_sensor_i2c_type addr_type;
enum camera_sensor_i2c_type data_type;
unsigned short delay;
};
/*struct i2c_settings_list {
struct cam_sensor_i2c_reg_setting i2c_settings;
enum cam_sensor_i2c_cmd_type op_code;
struct list_head list;
};
struct i2c_settings_array {
struct list_head list_head;
int32_t is_settings_valid;
int64_t request_id;
};
struct i2c_data_settings {
struct i2c_settings_array init_settings;
struct i2c_settings_array config_settings;
struct i2c_settings_array streamon_settings;
struct i2c_settings_array streamoff_settings;
struct i2c_settings_array *per_frame;
};*/
struct cam_sensor_power_ctrl_t {
struct device *dev;
struct cam_sensor_power_setting *power_setting;
uint16_t power_setting_size;
struct cam_sensor_power_setting *power_down_setting;
uint16_t power_down_setting_size;
struct msm_camera_gpio_num_info *gpio_num_info;
struct msm_pinctrl_info pinctrl_info;
uint8_t cam_pinctrl_status;
};
struct cam_camera_slave_info {
uint16_t sensor_slave_addr;
uint16_t sensor_id_reg_addr;
uint16_t sensor_id;
uint16_t sensor_id_mask;
};
struct msm_sensor_init_params {
int modes_supported;
unsigned int sensor_mount_angle;
};
enum msm_sensor_camera_id_t {
CAMERA_0,
CAMERA_1,
CAMERA_2,
CAMERA_3,
CAMERA_4,
CAMERA_5,
CAMERA_6,
MAX_CAMERAS,
};
struct msm_sensor_id_info_t {
unsigned short sensor_id_reg_addr;
unsigned short sensor_id;
unsigned short sensor_id_mask;
};
enum msm_sensor_output_format_t {
MSM_SENSOR_BAYER,
MSM_SENSOR_YCBCR,
MSM_SENSOR_META,
};
struct cam_sensor_power_setting {
enum msm_camera_power_seq_type seq_type;
unsigned short seq_val;
long config_val;
unsigned short delay;
void *data[10];
};
struct cam_sensor_board_info {
struct cam_camera_slave_info slave_info;
int32_t sensor_mount_angle;
int32_t secure_mode;
int modes_supported;
int32_t pos_roll;
int32_t pos_yaw;
int32_t pos_pitch;
int32_t subdev_id[SUB_MODULE_MAX];
int32_t subdev_intf[SUB_MODULE_MAX];
const char *misc_regulator;
struct cam_sensor_power_ctrl_t power_info;
};
enum msm_camera_vreg_name_t {
CAM_VDIG,
CAM_VIO,
CAM_VANA,
CAM_VAF,
CAM_V_CUSTOM1,
CAM_V_CUSTOM2,
CAM_VREG_MAX,
};
struct msm_camera_gpio_conf {
void *cam_gpiomux_conf_tbl;
uint8_t cam_gpiomux_conf_tbl_size;
struct gpio *cam_gpio_common_tbl;
uint8_t cam_gpio_common_tbl_size;
struct gpio *cam_gpio_req_tbl;
uint8_t cam_gpio_req_tbl_size;
uint32_t gpio_no_mux;
uint32_t *camera_off_table;
uint8_t camera_off_table_size;
uint32_t *camera_on_table;
uint8_t camera_on_table_size;
struct msm_camera_gpio_num_info *gpio_num_info;
};
/*for tof camera Begin*/
enum EEPROM_DATA_OP_T{
EEPROM_DEFAULT_DATA = 0,
EEPROM_INIT_DATA,
EEPROM_CONFIG_DATA,
EEPROM_STREAMON_DATA,
EEPROM_STREAMOFF_DATA,
EEPROM_OTHER_DATA,
};
/*for tof camera End*/
#endif /* _CAM_SENSOR_CMN_HEADER_ */

View File

@ -0,0 +1,134 @@
#ifndef __UAPI_CAM_SYNC_H__
#define __UAPI_CAM_SYNC_H__
#include <linux/videodev2.h>
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/media.h>
#define CAM_SYNC_DEVICE_NAME "cam_sync_device"
/* V4L event which user space will subscribe to */
#define CAM_SYNC_V4L_EVENT (V4L2_EVENT_PRIVATE_START + 0)
/* Specific event ids to get notified in user space */
#define CAM_SYNC_V4L_EVENT_ID_CB_TRIG 0
/* Size of opaque payload sent to kernel for safekeeping until signal time */
#define CAM_SYNC_USER_PAYLOAD_SIZE 2
/* Device type for sync device needed for device discovery */
#define CAM_SYNC_DEVICE_TYPE (MEDIA_ENT_F_OLD_BASE)
#define CAM_SYNC_GET_PAYLOAD_PTR(ev, type) \
(type *)((char *)ev.u.data + sizeof(struct cam_sync_ev_header))
#define CAM_SYNC_GET_HEADER_PTR(ev) \
((struct cam_sync_ev_header *)ev.u.data)
#define CAM_SYNC_STATE_INVALID 0
#define CAM_SYNC_STATE_ACTIVE 1
#define CAM_SYNC_STATE_SIGNALED_SUCCESS 2
#define CAM_SYNC_STATE_SIGNALED_ERROR 3
/**
* struct cam_sync_ev_header - Event header for sync event notification
*
* @sync_obj: Sync object
* @status: Status of the object
*/
struct cam_sync_ev_header {
int32_t sync_obj;
int32_t status;
};
/**
* struct cam_sync_info - Sync object creation information
*
* @name: Optional string representation of the sync object
* @sync_obj: Sync object returned after creation in kernel
*/
struct cam_sync_info {
char name[64];
int32_t sync_obj;
};
/**
* struct cam_sync_signal - Sync object signaling struct
*
* @sync_obj: Sync object to be signaled
* @sync_state: State of the sync object to which it should be signaled
*/
struct cam_sync_signal {
int32_t sync_obj;
uint32_t sync_state;
};
/**
* struct cam_sync_merge - Merge information for sync objects
*
* @sync_objs: Pointer to sync objects
* @num_objs: Number of objects in the array
* @merged: Merged sync object
*/
struct cam_sync_merge {
__u64 sync_objs;
uint32_t num_objs;
int32_t merged;
};
/**
* struct cam_sync_userpayload_info - Payload info from user space
*
* @sync_obj: Sync object for which payload has to be registered for
* @reserved: Reserved
* @payload: Pointer to user payload
*/
struct cam_sync_userpayload_info {
int32_t sync_obj;
uint32_t reserved;
__u64 payload[CAM_SYNC_USER_PAYLOAD_SIZE];
};
/**
* struct cam_sync_wait - Sync object wait information
*
* @sync_obj: Sync object to wait on
* @reserved: Reserved
* @timeout_ms: Timeout in milliseconds
*/
struct cam_sync_wait {
int32_t sync_obj;
uint32_t reserved;
uint64_t timeout_ms;
};
/**
* struct cam_private_ioctl_arg - Sync driver ioctl argument
*
* @id: IOCTL command id
* @size: Size of command payload
* @result: Result of command execution
* @reserved: Reserved
* @ioctl_ptr: Pointer to user data
*/
struct cam_private_ioctl_arg {
__u32 id;
__u32 size;
__u32 result;
__u32 reserved;
__u64 ioctl_ptr;
};
#define CAM_PRIVATE_IOCTL_CMD \
_IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_private_ioctl_arg)
#define CAM_SYNC_CREATE 0
#define CAM_SYNC_DESTROY 1
#define CAM_SYNC_SIGNAL 2
#define CAM_SYNC_MERGE 3
#define CAM_SYNC_REGISTER_PAYLOAD 4
#define CAM_SYNC_DEREGISTER_PAYLOAD 5
#define CAM_SYNC_WAIT 6
#endif /* __UAPI_CAM_SYNC_H__ */

View File

@ -4,6 +4,10 @@
#ifdef QCOM
#include "cameras/camera_qcom.h"
#elif QCOM2
#include "cameras/camera_qcom2.h"
#elif WEBCAM
#include "cameras/camera_webcam.h"
#else
#include "cameras/camera_frame_stream.h"
#endif
@ -18,6 +22,7 @@
#include "messaging.hpp"
#include "transforms/rgb_to_yuv.h"
#include "imgproc/utils.h"
#include "clutil.h"
#include "bufs.h"
@ -73,6 +78,14 @@ struct VisionState {
cl_kernel krnl_debayer_rear;
cl_kernel krnl_debayer_front;
cl_program prg_rgb_laplacian;
cl_kernel krnl_rgb_laplacian;
int conv_cl_localMemSize;
size_t conv_cl_globalWorkSize[2];
size_t conv_cl_localWorkSize[2];
size_t pool_cl_globalWorkSize[2];
// processing
TBuffer ui_tb;
TBuffer ui_front_tb;
@ -105,11 +118,15 @@ struct VisionState {
int rgb_width, rgb_height, rgb_stride;
VisionBuf rgb_bufs[UI_BUF_COUNT];
cl_mem rgb_bufs_cl[UI_BUF_COUNT];
cl_mem rgb_conv_roi_cl, rgb_conv_result_cl, rgb_conv_filter_cl;
uint16_t lapres[(ROI_X_MAX-ROI_X_MIN+1)*(ROI_Y_MAX-ROI_Y_MIN+1)];
size_t rgb_front_buf_size;
int rgb_front_width, rgb_front_height, rgb_front_stride;
VisionBuf rgb_front_bufs[UI_BUF_COUNT];
cl_mem rgb_front_bufs_cl[UI_BUF_COUNT];
bool rhd_front;
bool rhd_front_checked;
int front_meteringbox_xmin, front_meteringbox_xmax;
int front_meteringbox_ymin, front_meteringbox_ymax;
@ -148,7 +165,9 @@ void* frontview_thread(void *arg) {
// TODO: the loop is bad, ideally models shouldn't affect sensors
Context *msg_context = Context::create();
SubSocket *monitoring_sock = SubSocket::create(msg_context, "driverState", "127.0.0.1", true);
SubSocket *dmonstate_sock = SubSocket::create(msg_context, "dMonitoringState", "127.0.0.1", true);
assert(monitoring_sock != NULL);
assert(dmonstate_sock != NULL);
cl_command_queue q = clCreateCommandQueue(s->context, s->device_id, 0, &err);
assert(err == 0);
@ -160,32 +179,55 @@ void* frontview_thread(void *arg) {
}
int ui_idx = tbuffer_select(&s->ui_front_tb);
int rgb_idx = ui_idx;
FrameMetadata frame_data = s->cameras.front.camera_bufs_metadata[buf_idx];
double t1 = millis_since_boot();
err = clSetKernelArg(s->krnl_debayer_front, 0, sizeof(cl_mem), &s->front_camera_bufs_cl[buf_idx]);
assert(err == 0);
err = clSetKernelArg(s->krnl_debayer_front, 1, sizeof(cl_mem), &s->rgb_front_bufs_cl[ui_idx]);
assert(err == 0);
float digital_gain = 1.0;
err = clSetKernelArg(s->krnl_debayer_front, 2, sizeof(float), &digital_gain);
assert(err == 0);
cl_event debayer_event;
const size_t debayer_work_size = s->rgb_front_height;
const size_t debayer_local_work_size = 128;
err = clEnqueueNDRangeKernel(q, s->krnl_debayer_front, 1, NULL,
&debayer_work_size, &debayer_local_work_size, 0, 0, &debayer_event);
assert(err == 0);
if (s->cameras.front.ci.bayer) {
err = clSetKernelArg(s->krnl_debayer_front, 0, sizeof(cl_mem), &s->front_camera_bufs_cl[buf_idx]);
assert(err == 0);
err = clSetKernelArg(s->krnl_debayer_front, 1, sizeof(cl_mem), &s->rgb_front_bufs_cl[rgb_idx]);
assert(err == 0);
float digital_gain = 1.0;
err = clSetKernelArg(s->krnl_debayer_front, 2, sizeof(float), &digital_gain);
assert(err == 0);
const size_t debayer_work_size = s->rgb_front_height; // doesn't divide evenly, is this okay?
const size_t debayer_local_work_size = 128;
err = clEnqueueNDRangeKernel(q, s->krnl_debayer_front, 1, NULL,
&debayer_work_size, &debayer_local_work_size, 0, 0, &debayer_event);
assert(err == 0);
} else {
assert(s->rgb_front_buf_size >= s->cameras.front.frame_size);
assert(s->rgb_front_stride == s->cameras.front.ci.frame_stride);
err = clEnqueueCopyBuffer(q, s->front_camera_bufs_cl[buf_idx], s->rgb_front_bufs_cl[rgb_idx],
0, 0, s->rgb_front_buf_size, 0, 0, &debayer_event);
assert(err == 0);
}
clWaitForEvents(1, &debayer_event);
clReleaseEvent(debayer_event);
tbuffer_release(&s->cameras.front.camera_tb, buf_idx);
visionbuf_sync(&s->rgb_front_bufs[ui_idx], VISIONBUF_SYNC_FROM_DEVICE);
// set front camera metering target
// no more check after gps check
if (!s->rhd_front_checked) {
Message *msg_dmon = dmonstate_sock->receive(true);
if (msg_dmon != NULL) {
auto amsg = kj::heapArray<capnp::word>((msg_dmon->getSize() / sizeof(capnp::word)) + 1);
memcpy(amsg.begin(), msg_dmon->getData(), msg_dmon->getSize());
capnp::FlatArrayMessageReader cmsg(amsg);
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>();
s->rhd_front = event.getDMonitoringState().getIsRHD();
s->rhd_front_checked = event.getDMonitoringState().getRhdChecked();
delete msg_dmon;
}
}
Message *msg = monitoring_sock->receive(true);
if (msg != NULL) {
auto amsg = kj::heapArray<capnp::word>((msg->getSize() / sizeof(capnp::word)) + 1);
@ -202,7 +244,7 @@ void* frontview_thread(void *arg) {
// set front camera metering target
if (face_prob > 0.4)
{
int x_offset = s->rgb_front_width - 0.5 * s->rgb_front_height;
int x_offset = s->rhd_front ? 0:s->rgb_front_width - 0.5 * s->rgb_front_height;
s->front_meteringbox_xmin = x_offset + (face_position[0] + 0.5) * (0.5 * s->rgb_front_height) - 72;
s->front_meteringbox_xmax = x_offset + (face_position[0] + 0.5) * (0.5 * s->rgb_front_height) + 72;
s->front_meteringbox_ymin = (face_position[1] + 0.5) * (s->rgb_front_height) - 72;
@ -212,8 +254,8 @@ void* frontview_thread(void *arg) {
{
s->front_meteringbox_ymin = s->rgb_front_height * 1 / 3;
s->front_meteringbox_ymax = s->rgb_front_height * 1;
s->front_meteringbox_xmin = s->rgb_front_width * 3 / 5;
s->front_meteringbox_xmax = s->rgb_front_width;
s->front_meteringbox_xmin = s->rhd_front ? 0:s->rgb_front_width * 3 / 5;
s->front_meteringbox_xmax = s->rhd_front ? s->rgb_front_width * 2 / 5:s->rgb_front_width;
}
delete msg;
@ -242,8 +284,8 @@ void* frontview_thread(void *arg) {
{
y_start = s->rgb_front_height * 1 / 3;
y_end = s->rgb_front_height * 1;
x_start = s->rgb_front_width * 3 / 5;
x_end = s->rgb_front_width;
x_start = s->rhd_front ? 0:s->rgb_front_width * 3 / 5;
x_end = s->rhd_front ? s->rgb_front_width * 2 / 5:s->rgb_front_width;
}
uint32_t lum_binning[256] = {0,};
@ -288,27 +330,29 @@ void* frontview_thread(void *arg) {
// send frame event
{
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
if (s->front_frame_sock != NULL) {
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
auto framed = event.initFrontFrame();
framed.setFrameId(frame_data.frame_id);
framed.setEncodeId(cnt);
framed.setTimestampEof(frame_data.timestamp_eof);
framed.setFrameLength(frame_data.frame_length);
framed.setIntegLines(frame_data.integ_lines);
framed.setGlobalGain(frame_data.global_gain);
framed.setLensPos(frame_data.lens_pos);
framed.setLensSag(frame_data.lens_sag);
framed.setLensErr(frame_data.lens_err);
framed.setLensTruePos(frame_data.lens_true_pos);
framed.setGainFrac(frame_data.gain_frac);
framed.setFrameType(cereal::FrameData::FrameType::FRONT);
auto framed = event.initFrontFrame();
framed.setFrameId(frame_data.frame_id);
framed.setEncodeId(cnt);
framed.setTimestampEof(frame_data.timestamp_eof);
framed.setFrameLength(frame_data.frame_length);
framed.setIntegLines(frame_data.integ_lines);
framed.setGlobalGain(frame_data.global_gain);
framed.setLensPos(frame_data.lens_pos);
framed.setLensSag(frame_data.lens_sag);
framed.setLensErr(frame_data.lens_err);
framed.setLensTruePos(frame_data.lens_true_pos);
framed.setGainFrac(frame_data.gain_frac);
framed.setFrameType(cereal::FrameData::FrameType::FRONT);
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
s->front_frame_sock->send((char*)bytes.begin(), bytes.size());
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
s->front_frame_sock->send((char*)bytes.begin(), bytes.size());
}
}
/*FILE *f = fopen("/tmp/test2", "wb");
@ -324,6 +368,7 @@ void* frontview_thread(void *arg) {
}
delete monitoring_sock;
delete dmonstate_sock;
return NULL;
}
@ -369,9 +414,9 @@ void* processing_thread(void *arg) {
cl_event debayer_event;
if (s->cameras.rear.ci.bayer) {
err = clSetKernelArg(s->krnl_debayer_rear, 0, sizeof(cl_mem), &s->camera_bufs_cl[buf_idx]);
cl_check_error(err);
assert(err == 0);
err = clSetKernelArg(s->krnl_debayer_rear, 1, sizeof(cl_mem), &s->rgb_bufs_cl[rgb_idx]);
cl_check_error(err);
assert(err == 0);
err = clSetKernelArg(s->krnl_debayer_rear, 2, sizeof(float), &s->cameras.rear.digital_gain);
assert(err == 0);
@ -395,6 +440,74 @@ void* processing_thread(void *arg) {
visionbuf_sync(&s->rgb_bufs[rgb_idx], VISIONBUF_SYNC_FROM_DEVICE);
#ifdef QCOM
/*FILE *dump_rgb_file = fopen("/tmp/process_dump.rgb", "wb");
fwrite(s->rgb_bufs[rgb_idx].addr, s->rgb_bufs[rgb_idx].len, sizeof(uint8_t), dump_rgb_file);
fclose(dump_rgb_file);
printf("ORIGINAL SAVED!!\n");*/
/*double t10 = millis_since_boot();*/
// cache rgb roi and write to cl
uint8_t *rgb_roi_buf = new uint8_t[(s->rgb_width/NUM_SEGMENTS_X)*(s->rgb_height/NUM_SEGMENTS_Y)*3];
int roi_id = cnt % ((ROI_X_MAX-ROI_X_MIN+1)*(ROI_Y_MAX-ROI_Y_MIN+1)); // rolling roi
int roi_x_offset = roi_id % (ROI_X_MAX-ROI_X_MIN+1);
int roi_y_offset = roi_id / (ROI_X_MAX-ROI_X_MIN+1);
for (int r=0;r<(s->rgb_height/NUM_SEGMENTS_Y);r++) {
memcpy(rgb_roi_buf + r * (s->rgb_width/NUM_SEGMENTS_X) * 3,
(uint8_t *) s->rgb_bufs[rgb_idx].addr + \
(ROI_Y_MIN + roi_y_offset) * s->rgb_height/NUM_SEGMENTS_Y * FULL_STRIDE_X * 3 + \
(ROI_X_MIN + roi_x_offset) * s->rgb_width/NUM_SEGMENTS_X * 3 + r * FULL_STRIDE_X * 3,
s->rgb_width/NUM_SEGMENTS_X * 3);
}
err = clEnqueueWriteBuffer (q, s->rgb_conv_roi_cl, true, 0,
s->rgb_width/NUM_SEGMENTS_X * s->rgb_height/NUM_SEGMENTS_Y * 3 * sizeof(uint8_t), rgb_roi_buf, 0, 0, 0);
assert(err == 0);
/*double t11 = millis_since_boot();
printf("cache time: %f ms\n", t11 - t10);
t10 = millis_since_boot();*/
err = clSetKernelArg(s->krnl_rgb_laplacian, 0, sizeof(cl_mem), (void *) &s->rgb_conv_roi_cl);
assert(err == 0);
err = clSetKernelArg(s->krnl_rgb_laplacian, 1, sizeof(cl_mem), (void *) &s->rgb_conv_result_cl);
assert(err == 0);
err = clSetKernelArg(s->krnl_rgb_laplacian, 2, sizeof(cl_mem), (void *) &s->rgb_conv_filter_cl);
assert(err == 0);
err = clSetKernelArg(s->krnl_rgb_laplacian, 3, s->conv_cl_localMemSize, 0);
assert(err == 0);
cl_event conv_event;
err = clEnqueueNDRangeKernel(q, s->krnl_rgb_laplacian, 2, NULL,
s->conv_cl_globalWorkSize, s->conv_cl_localWorkSize, 0, 0, &conv_event);
assert(err == 0);
clWaitForEvents(1, &conv_event);
clReleaseEvent(conv_event);
int16_t *conv_result = new int16_t[(s->rgb_width/NUM_SEGMENTS_X)*(s->rgb_height/NUM_SEGMENTS_Y)];
err = clEnqueueReadBuffer(q, s->rgb_conv_result_cl, true, 0,
s->rgb_width/NUM_SEGMENTS_X * s->rgb_height/NUM_SEGMENTS_Y * sizeof(int16_t), conv_result, 0, 0, 0);
assert(err == 0);
/*t11 = millis_since_boot();
printf("conv time: %f ms\n", t11 - t10);
t10 = millis_since_boot();*/
get_lapmap_one(conv_result, &s->lapres[roi_id], s->rgb_width/NUM_SEGMENTS_X, s->rgb_height/NUM_SEGMENTS_Y);
/*t11 = millis_since_boot();
printf("pool time: %f ms\n", t11 - t10);
t10 = millis_since_boot();*/
delete [] rgb_roi_buf;
delete [] conv_result;
/*t11 = millis_since_boot();
printf("process time: %f ms\n ----- \n", t11 - t10);
t10 = millis_since_boot();*/
#endif
double t2 = millis_since_boot();
@ -421,43 +534,50 @@ void* processing_thread(void *arg) {
// send frame event
{
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
auto framed = event.initFrame();
framed.setFrameId(frame_data.frame_id);
framed.setEncodeId(cnt);
framed.setTimestampEof(frame_data.timestamp_eof);
framed.setFrameLength(frame_data.frame_length);
framed.setIntegLines(frame_data.integ_lines);
framed.setGlobalGain(frame_data.global_gain);
framed.setLensPos(frame_data.lens_pos);
framed.setLensSag(frame_data.lens_sag);
framed.setLensErr(frame_data.lens_err);
framed.setLensTruePos(frame_data.lens_true_pos);
framed.setGainFrac(frame_data.gain_frac);
#ifdef QCOM
kj::ArrayPtr<const int16_t> focus_vals(&s->cameras.rear.focus[0], NUM_FOCUS);
kj::ArrayPtr<const uint8_t> focus_confs(&s->cameras.rear.confidence[0], NUM_FOCUS);
framed.setFocusVal(focus_vals);
framed.setFocusConf(focus_confs);
#endif
#ifndef QCOM
framed.setImage(kj::arrayPtr((const uint8_t*)s->yuv_ion[yuv_idx].addr, s->yuv_buf_size));
#endif
kj::ArrayPtr<const float> transform_vs(&s->yuv_transform.v[0], 9);
framed.setTransform(transform_vs);
if (s->frame_sock != NULL) {
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
auto framed = event.initFrame();
framed.setFrameId(frame_data.frame_id);
framed.setEncodeId(cnt);
framed.setTimestampEof(frame_data.timestamp_eof);
framed.setFrameLength(frame_data.frame_length);
framed.setIntegLines(frame_data.integ_lines);
framed.setGlobalGain(frame_data.global_gain);
framed.setLensPos(frame_data.lens_pos);
framed.setLensSag(frame_data.lens_sag);
framed.setLensErr(frame_data.lens_err);
framed.setLensTruePos(frame_data.lens_true_pos);
framed.setGainFrac(frame_data.gain_frac);
#ifdef QCOM
kj::ArrayPtr<const int16_t> focus_vals(&s->cameras.rear.focus[0], NUM_FOCUS);
kj::ArrayPtr<const uint8_t> focus_confs(&s->cameras.rear.confidence[0], NUM_FOCUS);
framed.setFocusVal(focus_vals);
framed.setFocusConf(focus_confs);
kj::ArrayPtr<const uint16_t> sharpness_score(&s->lapres[0], (ROI_X_MAX-ROI_X_MIN+1)*(ROI_Y_MAX-ROI_Y_MIN+1));
framed.setSharpnessScore(sharpness_score);
#endif
// TODO: add this back
#if !defined(QCOM) && !defined(QCOM2)
//#ifndef QCOM
framed.setImage(kj::arrayPtr((const uint8_t*)s->yuv_ion[yuv_idx].addr, s->yuv_buf_size));
#endif
kj::ArrayPtr<const float> transform_vs(&s->yuv_transform.v[0], 9);
framed.setTransform(transform_vs);
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
s->frame_sock->send((char*)bytes.begin(), bytes.size());
}
}
#ifndef QCOM2
// TODO: fix on QCOM2, giving scanline error
// one thumbnail per 5 seconds (instead of %5 == 0 posenet)
if (cnt % 100 == 3) {
uint8_t* thumbnail_buffer = NULL;
@ -521,6 +641,7 @@ void* processing_thread(void *arg) {
free(thumbnail_buffer);
}
#endif
tbuffer_dispatch(&s->ui_tb, ui_idx);
@ -862,18 +983,52 @@ cl_program build_debayer_program(VisionState *s,
assert(rgb_width == frame_width/2);
assert(rgb_height == frame_height/2);
#ifdef QCOM2
int dnew = 1;
#else
int dnew = 0;
#endif
char args[4096];
snprintf(args, sizeof(args),
"-cl-fast-relaxed-math -cl-denorms-are-zero "
"-DFRAME_WIDTH=%d -DFRAME_HEIGHT=%d -DFRAME_STRIDE=%d "
"-DRGB_WIDTH=%d -DRGB_HEIGHT=%d -DRGB_STRIDE=%d "
"-DBAYER_FLIP=%d -DHDR=%d",
"-DBAYER_FLIP=%d -DHDR=%d -DNEW=%d",
frame_width, frame_height, frame_stride,
rgb_width, rgb_height, rgb_stride,
bayer_flip, hdr);
bayer_flip, hdr, dnew);
return CLU_LOAD_FROM_FILE(s->context, s->device_id, "cameras/debayer.cl", args);
}
cl_program build_conv_program(VisionState *s,
int image_w, int image_h,
int filter_size) {
char args[4096];
snprintf(args, sizeof(args),
"-cl-fast-relaxed-math -cl-denorms-are-zero "
"-DIMAGE_W=%d -DIMAGE_H=%d -DFLIP_RB=%d "
"-DFILTER_SIZE=%d -DHALF_FILTER_SIZE=%d -DTWICE_HALF_FILTER_SIZE=%d -DHALF_FILTER_SIZE_IMAGE_W=%d",
image_w, image_h, 1,
filter_size, filter_size/2, (filter_size/2)*2, (filter_size/2)*image_w);
return CLU_LOAD_FROM_FILE(s->context, s->device_id, "imgproc/conv.cl", args);
}
cl_program build_pool_program(VisionState *s,
int full_stride_x,
int x_pitch, int y_pitch,
int roi_x_min, int roi_x_max,
int roi_y_min, int roi_y_max) {
char args[4096];
snprintf(args, sizeof(args),
"-cl-fast-relaxed-math -cl-denorms-are-zero "
"-DFULL_STRIDE_X=%d -DX_PITCH=%d -DY_PITCH=%d "
"-DROI_X_MIN=%d -DROI_X_MAX=%d -DROI_Y_MIN=%d -DROI_Y_MAX=%d",
full_stride_x, x_pitch, y_pitch,
roi_x_min, roi_x_max, roi_y_min, roi_y_max);
return CLU_LOAD_FROM_FILE(s->context, s->device_id, "imgproc/pool.cl", args);
}
void cl_init(VisionState *s) {
int err;
cl_platform_id platform_id = NULL;
@ -908,9 +1063,11 @@ void init_buffers(VisionState *s) {
for (int i=0; i<FRAME_BUF_COUNT; i++) {
s->camera_bufs[i] = visionbuf_allocate_cl(s->frame_size, s->device_id, s->context,
&s->camera_bufs_cl[i]);
// TODO: make lengths correct
s->focus_bufs[i] = visionbuf_allocate(0xb80);
s->stats_bufs[i] = visionbuf_allocate(0xb80);
#ifndef QCOM2
// TODO: make lengths correct
s->focus_bufs[i] = visionbuf_allocate(0xb80);
s->stats_bufs[i] = visionbuf_allocate(0xb80);
#endif
}
for (int i=0; i<FRAME_BUF_COUNT; i++) {
@ -939,8 +1096,14 @@ void init_buffers(VisionState *s) {
tbuffer_init(&s->ui_tb, UI_BUF_COUNT, "rgb");
//assert(s->cameras.front.ci.bayer);
s->rgb_front_width = s->cameras.front.ci.frame_width/2;
s->rgb_front_height = s->cameras.front.ci.frame_height/2;
if (s->cameras.front.ci.bayer) {
s->rgb_front_width = s->cameras.front.ci.frame_width/2;
s->rgb_front_height = s->cameras.front.ci.frame_height/2;
} else {
s->rgb_front_width = s->cameras.front.ci.frame_width;
s->rgb_front_height = s->cameras.front.ci.frame_height;
}
for (int i=0; i<UI_BUF_COUNT; i++) {
VisionImg img = visionimg_alloc_rgb24(s->rgb_front_width, s->rgb_front_height, &s->rgb_front_bufs[i]);
@ -1008,6 +1171,25 @@ void init_buffers(VisionState *s) {
assert(err == 0);
}
s->prg_rgb_laplacian = build_conv_program(s, s->rgb_width/NUM_SEGMENTS_X, s->rgb_height/NUM_SEGMENTS_Y,
3);
s->krnl_rgb_laplacian = clCreateKernel(s->prg_rgb_laplacian, "rgb2gray_conv2d", &err);
assert(err == 0);
s->rgb_conv_roi_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
s->rgb_width/NUM_SEGMENTS_X * s->rgb_height/NUM_SEGMENTS_Y * 3 * sizeof(uint8_t), NULL, NULL);
s->rgb_conv_result_cl = clCreateBuffer(s->context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
s->rgb_width/NUM_SEGMENTS_X * s->rgb_height/NUM_SEGMENTS_Y * sizeof(int16_t), NULL, NULL);
s->rgb_conv_filter_cl = clCreateBuffer(s->context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
9 * sizeof(int16_t), (void*)&lapl_conv_krnl, NULL);
s->conv_cl_localMemSize = ( CONV_LOCAL_WORKSIZE + 2 * (3 / 2) ) * ( CONV_LOCAL_WORKSIZE + 2 * (3 / 2) );
s->conv_cl_localMemSize *= 3 * sizeof(uint8_t);
s->conv_cl_globalWorkSize[0] = s->rgb_width/NUM_SEGMENTS_X;
s->conv_cl_globalWorkSize[1] = s->rgb_height/NUM_SEGMENTS_Y;
s->conv_cl_localWorkSize[0] = CONV_LOCAL_WORKSIZE;
s->conv_cl_localWorkSize[1] = CONV_LOCAL_WORKSIZE;
for (int i=0; i<(ROI_X_MAX-ROI_X_MIN+1)*(ROI_Y_MAX-ROI_Y_MIN+1); i++) {s->lapres[i] = 16160;}
rgb_to_yuv_init(&s->rgb_to_yuv_state, s->context, s->device_id, s->yuv_width, s->yuv_height, s->rgb_stride);
rgb_to_yuv_init(&s->front_rgb_to_yuv_state, s->context, s->device_id, s->yuv_front_width, s->yuv_front_height, s->rgb_front_stride);
}
@ -1053,10 +1235,13 @@ void party(VisionState *s) {
processing_thread, s);
assert(err == 0);
#ifndef QCOM2
// TODO: fix front camera on qcom2
pthread_t frontview_thread_handle;
err = pthread_create(&frontview_thread_handle, NULL,
frontview_thread, s);
assert(err == 0);
#endif
// priority for cameras
err = set_realtime_priority(1);
@ -1071,9 +1256,11 @@ void party(VisionState *s) {
zsock_signal(s->terminate_pub, 0);
#ifndef QCOM2
LOG("joining frontview_thread");
err = pthread_join(frontview_thread_handle, NULL);
assert(err == 0);
#endif
LOG("joining visionserver_thread");
err = pthread_join(visionserver_thread_handle, NULL);
@ -1109,7 +1296,7 @@ int main(int argc, char *argv[]) {
init_buffers(s);
#ifdef QCOM
#if defined(QCOM) || defined(QCOM2)
s->msg_context = Context::create();
s->frame_sock = PubSocket::create(s->msg_context, "frame");
s->front_frame_sock = PubSocket::create(s->msg_context, "frontFrame");
@ -1123,7 +1310,7 @@ int main(int argc, char *argv[]) {
party(s);
#ifdef QCOM
#if defined(QCOM) || defined(QCOM2)
delete s->frame_sock;
delete s->front_frame_sock;
delete s->thumbnail_sock;

View File

@ -22,6 +22,9 @@ def snapshot():
params = Params()
front_camera_allowed = int(params.get("RecordFront"))
if params.get("IsTakingSnapshot") == b"1":
return None
params.put("IsTakingSnapshot", "1")
params.put("Offroad_IsTakingSnapshot", json.dumps(OFFROAD_ALERTS["Offroad_IsTakingSnapshot"]))
time.sleep(2.0) # Give thermald time to read the param, or if just started give camerad time to start

View File

@ -8,6 +8,7 @@
void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride) {
int err = 0;
memset(s, 0, sizeof(*s));
printf("width %d, height %d, rgb_stride %d\n", width, height, rgb_stride);
assert(width % 2 == 0);
assert(height % 2 == 0);
s->width = width;

View File

@ -27,12 +27,17 @@ def load_interfaces(brand_names):
for brand_name in brand_names:
path = ('selfdrive.car.%s' % brand_name)
CarInterface = __import__(path + '.interface', fromlist=['CarInterface']).CarInterface
if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carcontroller.py'):
CarController = __import__(path + '.carcontroller', fromlist=['CarController']).CarController
if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carstate.py'):
CarState = __import__(path + '.carstate', fromlist=['CarState']).CarState
else:
CarController = None
CarState = None
if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carcontroller.py'):
CarController = __import__(path + '.carcontroller', fromlist=['CarController']).CarController
else:
CarController = None
for model_name in brand_names[brand_name]:
ret[model_name] = (CarInterface, CarController, CarState)
return ret
@ -66,7 +71,9 @@ def only_toyota_left(candidate_cars):
# **** for use live only ****
def fingerprint(logcan, sendcan, has_relay):
if has_relay:
fixed_fingerprint = os.environ.get('FINGERPRINT', "")
if has_relay and not fixed_fingerprint:
# Vin query only reliably works thorugh OBDII
bus = 1
@ -141,8 +148,7 @@ def fingerprint(logcan, sendcan, has_relay):
car_fingerprint = list(fw_candidates)[0]
source = car.CarParams.FingerprintSource.fw
fixed_fingerprint = os.environ.get('FINGERPRINT', "")
if len(fixed_fingerprint):
if fixed_fingerprint:
car_fingerprint = fixed_fingerprint
source = car.CarParams.FingerprintSource.fixed

View File

@ -6,7 +6,6 @@ from opendbc.can.packer import CANPacker
class CarController():
def __init__(self, dbc_name, CP, VM):
self.braking = False
self.apply_steer_last = 0
self.ccframe = 0
self.prev_frame = -1
@ -51,7 +50,7 @@ class CarController():
if pcm_cancel_cmd:
# TODO: would be better to start from frame_2b3
new_msg = create_wheel_buttons(self.ccframe)
new_msg = create_wheel_buttons(self.packer, self.ccframe, cancel=True)
can_sends.append(new_msg)
# LKAS_HEARTBIT is forwarded by Panda so no need to send it here.

View File

@ -54,7 +54,7 @@ class CarState(CarStateBase):
ret.steeringTorqueEps = cp.vl["EPS_STATUS"]["TORQUE_MOTOR"]
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
steer_state = cp.vl["EPS_STATUS"]["LKAS_STATE"]
self.steer_error = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed)
ret.steerError = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed)
ret.genericToggle = bool(cp.vl["STEERING_LEVERS"]['HIGH_BEAM_FLASH'])

View File

@ -5,34 +5,6 @@ from selfdrive.car import make_can_msg
GearShifter = car.CarState.GearShifter
VisualAlert = car.CarControl.HUDControl.VisualAlert
def calc_checksum(data):
"""This function does not want the checksum byte in the input data.
jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf
"""
checksum = 0xFF
for curr in data[:-1]:
shift = 0x80
for i in range(0, 8):
bit_sum = curr & shift
temp_chk = checksum & 0x80
if (bit_sum != 0):
bit_sum = 0x1C
if (temp_chk != 0):
bit_sum = 1
checksum = checksum << 1
temp_chk = checksum | 1
bit_sum ^= temp_chk
else:
if (temp_chk != 0):
bit_sum = 0x1D
checksum = checksum << 1
bit_sum ^= checksum
checksum = bit_sum
shift = shift >> 1
return ~checksum & 0xFF
def create_lkas_hud(packer, gear, lkas_active, hud_alert, hud_count, lkas_car_model):
# LKAS_HUD 0x2a6 (678) Controls what lane-keeping icon is displayed.
@ -73,18 +45,13 @@ def create_lkas_command(packer, apply_steer, moving_fast, frame):
"LKAS_HIGH_TORQUE": int(moving_fast),
"COUNTER": frame % 0x10,
}
dat = packer.make_can_msg("LKAS_COMMAND", 0, values)[2]
checksum = calc_checksum(dat)
values["CHECKSUM"] = checksum
return packer.make_can_msg("LKAS_COMMAND", 0, values)
def create_wheel_buttons(frame):
def create_wheel_buttons(packer, frame, cancel=False):
# WHEEL_BUTTONS (571) Message sent to cancel ACC.
start = b"\x01" # acc cancel set
counter = (frame % 10) << 4
dat = start + counter.to_bytes(1, 'little') + b"\x00"
dat = dat[:-1] + calc_checksum(dat).to_bytes(1, 'little')
return make_can_msg(0x23b, dat, 0)
values = {
"ACC_CANCEL": cancel,
"COUNTER": frame % 10
}
return packer.make_can_msg("WHEEL_BUTTONS", 0, values)

View File

@ -1,13 +1,12 @@
#!/usr/bin/env python3
from cereal import car
from selfdrive.config import Conversions as CV
from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event
from selfdrive.car.chrysler.values import Ecu, ECU_FINGERPRINT, CAR, FINGERPRINTS
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint
from selfdrive.car.interfaces import CarInterfaceBase
class CarInterface(CarInterfaceBase):
class CarInterface(CarInterfaceBase):
@staticmethod
def compute_gb(accel, speed):
return float(accel) / 3.0
@ -18,6 +17,9 @@ class CarInterface(CarInterfaceBase):
ret.carName = "chrysler"
ret.safetyModel = car.CarParams.SafetyModel.chrysler
# Chrysler port is a community feature, since we don't own one to test
ret.communityFeature = True
# Speed conversion: 20, 45 mph
ret.wheelbase = 3.089 # in meters for Pacifica Hybrid 2017
ret.steerRatio = 16.2 # Pacifica Hybrid 2017
@ -37,7 +39,7 @@ class CarInterface(CarInterfaceBase):
ret.centerToFront = ret.wheelbase * 0.44
ret.minSteerSpeed = 3.8 # m/s
if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.JEEP_CHEROKEE_2019):
if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020, CAR.JEEP_CHEROKEE_2019):
# TODO allow 2019 cars to steer down to 13 m/s if already engaged.
ret.minSteerSpeed = 17.5 # m/s 17 on the way up, 13 on the way down once engaged.
@ -64,28 +66,18 @@ class CarInterface(CarInterfaceBase):
ret.canValid = self.cp.can_valid and self.cp_cam.can_valid
# speeds
ret.yawRate = self.VM.yaw_rate(ret.steeringAngle * CV.DEG_TO_RAD, ret.vEgo)
ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False
ret.buttonEvents = []
# events
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low], gas_resume_speed = 2.)
if ret.cruiseState.enabled and not self.cruise_enabled_prev:
events.append(create_event('pcmEnable', [ET.ENABLE]))
elif not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low], gas_resume_speed=2.)
if ret.vEgo < self.CP.minSteerSpeed:
events.append(create_event('belowSteerSpeed', [ET.WARNING]))
ret.events = events
self.gas_pressed_prev = ret.gasPressed
self.brake_pressed_prev = ret.brakePressed
self.cruise_enabled_prev = ret.cruiseState.enabled
# copy back carState packet to CS
self.CS.out = ret.as_reader()

View File

@ -48,8 +48,7 @@ def _address_to_track(address):
class RadarInterface(RadarInterfaceBase):
def __init__(self, CP):
self.pts = {}
self.delay = 0 # Delay of radar #TUNE
super().__init__(CP)
self.rcp = _create_radar_can_parser()
self.updated_messages = set()
self.trigger_msg = LAST_MSG

View File

@ -11,10 +11,6 @@ GearShifter = car.CarState.GearShifter
class TestChryslerCan(unittest.TestCase):
def test_checksum(self):
self.assertEqual(0x75, chryslercan.calc_checksum(b"\x01\x20\x00"))
self.assertEqual(0xcc, chryslercan.calc_checksum(b"\x14\x00\x00\x00\x20\x00"))
def test_hud(self):
packer = CANPacker('chrysler_pacifica_2017_hybrid')
self.assertEqual(

View File

@ -16,6 +16,7 @@ class CAR:
PACIFICA_2018_HYBRID = "CHRYSLER PACIFICA HYBRID 2018"
PACIFICA_2019_HYBRID = "CHRYSLER PACIFICA HYBRID 2019"
PACIFICA_2018 = "CHRYSLER PACIFICA 2018" # Also covers Pacifica 2017.
PACIFICA_2020 = "CHRYSLER PACIFICA 2020"
JEEP_CHEROKEE = "JEEP GRAND CHEROKEE V6 2018" # Also covers Tailhawk 2017.
JEEP_CHEROKEE_2019 = "JEEP GRAND CHEROKEE 2019"
@ -38,6 +39,11 @@ FINGERPRINTS = {
{55: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 516: 7, 517: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 8, 926: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8},
{55: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 516: 7, 517: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 3, 926: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8},
],
CAR.PACIFICA_2020: [
{
55: 8, 179: 8, 181: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 650: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 906: 8, 924: 8, 926: 3, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1223: 7, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1284: 8, 1568: 8, 1856: 8, 1858: 8, 1860: 8, 1863: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 2016: 8, 2024: 8
}
],
CAR.PACIFICA_2018_HYBRID: [
{68: 8, 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8},
# based on 9ae7821dc4e92455|2019-07-01--16-42-55
@ -68,9 +74,9 @@ FINGERPRINTS = {
{257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 658: 6, 660: 8, 671: 8, 672: 8, 680: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 783: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8},
],
CAR.JEEP_CHEROKEE_2019: [
# Jeep Grand Cherokee 2019 from Switzerland
# Jeep Grand Cherokee 2019
# 530: 8 is so far only in this Jeep.
{55: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 530: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 658: 6, 660: 8, 671: 8, 672: 8, 676: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 792: 8, 799: 8, 804: 8, 806: 2, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8},
{55: 8, 168: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 530: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 785: 8, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 840: 8, 844: 5, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 976: 8, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8, 1543: 8, 2015: 8, 2016: 8, 2024: 8},
],
}
@ -82,6 +88,9 @@ DBC = {
CAR.PACIFICA_2018: dbc_dict( # Same DBC file works.
'chrysler_pacifica_2017_hybrid', # 'pt'
'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar'
CAR.PACIFICA_2020: dbc_dict( # Same DBC file works.
'chrysler_pacifica_2017_hybrid', # 'pt'
'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar'
CAR.PACIFICA_2018_HYBRID: dbc_dict( # Same DBC file works.
'chrysler_pacifica_2017_hybrid', # 'pt'
'chrysler_pacifica_2017_hybrid_private_fusion'), # 'radar'

View File

@ -19,6 +19,7 @@ class CarState(CarStateBase):
ret.standstill = not ret.vEgoRaw > 0.001
ret.steeringAngle = cp.vl["Steering_Wheel_Data_CG1"]['SteWhlRelInit_An_Sns']
ret.steeringPressed = not cp.vl["Lane_Keep_Assist_Status"]['LaHandsOff_B_Actl']
ret.steerError = cp.vl["Lane_Keep_Assist_Status"]['LaActDeny_B_Actl'] == 1
ret.cruiseState.speed = cp.vl["Cruise_Status"]['Set_Speed'] * CV.MPH_TO_MS
ret.cruiseState.enabled = not (cp.vl["Cruise_Status"]['Cruise_State'] in [0, 3])
ret.cruiseState.available = cp.vl["Cruise_Status"]['Cruise_State'] != 0
@ -29,7 +30,6 @@ class CarState(CarStateBase):
ret.genericToggle = bool(cp.vl["Steering_Buttons"]["Dist_Incr"])
# TODO: we also need raw driver torque, needed for Assisted Lane Change
self.lkas_state = cp.vl["Lane_Keep_Assist_Status"]['LaActAvail_D_Actl']
self.steer_error = cp.vl["Lane_Keep_Assist_Status"]['LaActDeny_B_Actl']
return ret

View File

@ -61,23 +61,12 @@ class CarInterface(CarInterfaceBase):
# events
events = self.create_common_events(ret)
# enable request in prius is simple, as we activate when Toyota is active (rising edge)
if ret.cruiseState.enabled and not self.cruise_enabled_prev:
events.append(create_event('pcmEnable', [ET.ENABLE]))
elif not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
if self.CS.lkas_state not in [2, 3] and ret.vEgo > 13.* CV.MPH_TO_MS and ret.cruiseState.enabled:
events.append(create_event('steerTempUnavailableMute', [ET.WARNING]))
ret.events = events
self.gas_pressed_prev = ret.gasPressed
self.brake_pressed_prev = ret.brakePressed
self.cruise_enabled_prev = ret.cruiseState.enabled
self.CS.out = ret.as_reader()
return self.CS.out
# pass in a car.CarControl

Some files were not shown because too many files have changed in this diff Show More